当前位置: 首页>>代码示例>>PHP>>正文


PHP ContentHelper::getAssociations方法代码示例

本文整理汇总了PHP中ContentHelper::getAssociations方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentHelper::getAssociations方法的具体用法?PHP ContentHelper::getAssociations怎么用?PHP ContentHelper::getAssociations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ContentHelper的用法示例。


在下文中一共展示了ContentHelper::getAssociations方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: association

 /**
  * @param	int $articleid	The article item id
  */
 public static function association($articleid)
 {
     // Get the associations
     $associations = ContentHelper::getAssociations($articleid);
     foreach ($associations as $tag => $associated) {
         $associations[$tag] = (int) $associated->id;
     }
     // Get the associated menu items
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('c.*');
     $query->from('#__content as c');
     $query->select('cat.title as category_title');
     $query->leftJoin('#__categories as cat ON cat.id=c.catid');
     $query->where('c.id IN (' . implode(',', array_values($associations)) . ')');
     $query->leftJoin('#__languages as l ON c.language=l.lang_code');
     $query->select('l.image');
     $query->select('l.title as language_title');
     $db->setQuery($query);
     $items = $db->loadObjectList('id');
     // Check for a database error.
     if ($error = $db->getErrorMsg()) {
         JError::raiseWarning(500, $error);
         return false;
     }
     // Construct html
     $text = array();
     foreach ($associations as $tag => $associated) {
         if ($associated != $articleid) {
             $text[] = JText::sprintf('COM_CONTENT_TIP_ASSOCIATED_LANGUAGE', JHtml::_('image', 'mod_languages/' . $items[$associated]->image . '.gif', $items[$associated]->language_title, array('title' => $items[$associated]->language_title), true), $items[$associated]->title, $items[$associated]->category_title);
         }
     }
     return JHtml::_('tooltip', implode('<br />', $text), JText::_('COM_CONTENT_TIP_ASSOCIATION'), 'admin/icon-16-links.png');
 }
开发者ID:ngxuanmui,项目名称:thongtinonline.net,代码行数:37,代码来源:contentadministrator.php

示例2: getAssociations

 /**
  * Method to get the associations for a given item
  *
  * @param   integer  $id    Id of the item
  * @param   string   $view  Name of the view
  *
  * @return  array   Array of associations for the item
  *
  * @since  3.0
  */
 public static function getAssociations($id = 0, $view = null)
 {
     jimport('helper.route', JPATH_COMPONENT_SITE);
     $app = JFactory::getApplication();
     $jinput = $app->input;
     $view = is_null($view) ? $jinput->get('view') : $view;
     $id = empty($id) ? $jinput->getInt('id') : $id;
     if ($view == 'article') {
         if ($id) {
             $associations = ContentHelper::getAssociations($id);
             $return = array();
             foreach ($associations as $tag => $item) {
                 $return[$tag] = ContentHelperRoute::getArticleRoute($item->id, $item->catid, $item->language);
             }
             return $return;
         }
     }
     if ($view == 'category' || $view == 'categories') {
         return self::getCategoryAssociations($id, 'com_content');
     }
     return array();
 }
开发者ID:interfaceslivres,项目名称:ccmd-ufpb,代码行数:32,代码来源:association.php

示例3: getItem

 /**
  * Method to get a single record.
  *
  * @param	integer	The id of the primary key.
  *
  * @return	mixed	Object on success, false on failure.
  */
 public function getItem($pk = null)
 {
     if ($item = parent::getItem($pk)) {
         // Convert the params field to an array.
         $registry = new JRegistry();
         $registry->loadString($item->attribs);
         $item->attribs = $registry->toArray();
         // Convert the metadata field to an array.
         $registry = new JRegistry();
         $registry->loadString($item->metadata);
         $item->metadata = $registry->toArray();
         // Convert the images field to an array.
         $registry = new JRegistry();
         $registry->loadString($item->images);
         $item->images = $registry->toArray();
         // Convert the urls field to an array.
         $registry = new JRegistry();
         $registry->loadString($item->urls);
         $item->urls = $registry->toArray();
         $item->articletext = trim($item->fulltext) != '' ? $item->introtext . "<hr id=\"system-readmore\" />" . $item->fulltext : $item->introtext;
     }
     // Load associated content items
     $app = JFactory::getApplication();
     $assoc = isset($app->item_associations) ? $app->item_associations : 0;
     if ($assoc) {
         $item->associations = array();
         if ($item->id != null) {
             $associations = ContentHelper::getAssociations($item->id);
             foreach ($associations as $tag => $association) {
                 $item->associations[$tag] = $association->id;
             }
         }
     }
     return $item;
 }
开发者ID:rasiodesign,项目名称:joomla-cms,代码行数:42,代码来源:article.php


注:本文中的ContentHelper::getAssociations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。