Ejemplo n.º 1
0
 public static function getK2Item($id, $addFields = '')
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $where = array('a.published=1', 'a.trash=0');
     if ($id != 0) {
         $where[] = 'id=' . (int) $id;
     }
     $query->select('a.id,a.title,a.alias,a.extra_fields,a.introtext,a.fulltext,a.catid')->select('a.created,a.modified,a.created_by,a.created_by_alias,a.ordering,a.image_caption,a.image_credits,a.params');
     if (!empty($addFields)) {
         $query->select($addFields);
     }
     $query->from('#__k2_items AS a')->where($where);
     //->join('INNER', '#__k2_categories AS c ON (a.catid = c.id)');
     $db->setQuery($query);
     $item = $db->loadObject();
     require_once JPATH_SITE . '/components/com_k2/helpers/route.php';
     require_once JPATH_BASE . '/components/com_k2/models/item.php';
     require_once JPATH_BASE . '/components/com_k2/helpers/permissions.php';
     JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS . 'tables');
     $K2ModelItem = new K2ModelItem();
     $item = $K2ModelItem->prepareItem($item, 'category', 'itemlist');
     return $item;
 }