public function render($params = array()) { $linked = isset($params['linked']) && $params['linked']; $values = array(); foreach ($this->_item->getRelatedCategories(true) as $category) { $values[] = $linked ? '<a href="' . JRoute::_(RouteHelper::getCategoryRoute($category)) . '">' . $category->name . '</a>' : $category->name; } return ElementHelper::applySeparators($params['separated_by'], $values); }
public function render($params = array()) { $category_ids = $this->_data->get('category', array()); $category_links = array(); $categories = YTable::getInstance('category')->getById($category_ids, true); foreach ($categories as $category) { $category_links[] = '<a href="' . RouteHelper::getCategoryRoute($category) . '">' . $category->name . '</a>'; } return ElementHelper::applySeparators($params['separated_by'], $category_links); }
public static function render($category, $params, $level) { // init vars $menu_item = $params->get('menu_item'); $max_depth = $params->get('depth', 0); if ($menu_item) { $url = 'index.php?option=com_zoo&task=category&category_id=' . $category->id . '&Itemid=' . $menu_item; } else { $url = RouteHelper::getCategoryRoute($category); } $result = array(); $result[] = '<li>'; $result[] = '<a href="' . JRoute::_($url) . '">' . $category->name . '</a>'; if ((!$max_depth || $max_depth >= $level) && ($children = $category->getChildren()) && !empty($children)) { $result[] = '<ul class="level' . $level . '">'; foreach ($children as $child) { $result[] = self::render($child, $params, $level + 1); } $result[] = '</ul>'; } $result[] = '</li>'; return implode("\n", $result); }
public function category() { // get request vars $page = YRequest::getInt('page', 1); $category_id = (int) YRequest::getInt('category_id', $this->params->get('category')); // init vars $this->category = YTable::getInstance('category')->get($category_id); $params = $this->category ? $this->category->getParams('site') : $this->application->getParams('frontpage'); $this->item_order = $this->_getItemOrder($params->get('config.item_order')); $layout = $category_id == 0 ? 'frontpage' : 'category'; // get categories and items $this->categories = $this->application->getCategoryTree(true, $this->user, true); $this->items = YTable::getInstance('item')->getFromCategory($this->application->id, $category_id, true, null, $this->item_order); // raise warning when category can not be accessed if (!isset($this->categories[$category_id])) { JError::raiseWarning(500, JText::_('Unable to access category')); return; } // set category and categories to display $this->category = $this->categories[$category_id]; $this->selected_categories = $this->categories[$category_id]->getChildren(); // get item pagination $items_per_page = $params->get('config.items_per_page', 15); $this->pagination = new YPagination('page', count($this->items), $page, $items_per_page); $this->pagination->setShowAll($items_per_page == 0); if ($layout == 'category') { $this->pagination_link = RouteHelper::getCategoryRoute($this->category); } else { $this->pagination_link = RouteHelper::getFrontpageRoute($this->application->id); } // slice out items if (!$this->pagination->getShowAll()) { $this->items = array_slice($this->items, $this->pagination->limitStart(), $items_per_page); } // create pathway $addpath = false; $catid = $this->params->get('category'); foreach ($this->category->getPathway() as $cat) { if (!$catid || $addpath) { $link = RouteHelper::getCategoryRoute($cat); $this->pathway->addItem($cat->name, $link); } if ($catid && $catid == $cat->id) { $addpath = true; } } // add feed links if ($params->get('config.show_feed_link')) { if ($alternate = $params->get('config.alternate_feed_link')) { $this->document->addHeadLink($alternate, 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0')); } else { $this->document->addHeadLink(JRoute::_(RouteHelper::getFeedRoute($this->category, 'rss')), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0')); $this->document->addHeadLink(JRoute::_(RouteHelper::getFeedRoute($this->category, 'atom')), 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0')); } } // set alphaindex if ($params->get('template.show_alpha_index')) { $this->alpha_index = $this->_getAlphaindex(); } // set template and params if (!($this->template = $this->application->getTemplate())) { JError::raiseError(500, JText::_('No template selected')); return; } $this->params = $params; // set renderer $this->renderer = new ItemRenderer(); $this->renderer->addPath(array($this->template->getPath(), ZOO_SITE_PATH)); // display view $this->getView($layout)->addTemplatePath($this->template->getPath())->setLayout($layout)->display(); }