public function render($params = array()) { $linked = isset($params['linked']) && $params['linked']; $values = array(); if ($linked) { foreach ($this->_item->getTags() as $tag) { $values[] = '<a href="' . JRoute::_(RouteHelper::getTagRoute($this->_item->application_id, $tag)) . '">' . $tag . '</a>'; } } else { $values = $this->_item->getTags(); } return ElementHelper::applySeparators($params['separated_by'], $values); }
public static function buildTagCloud($app, $params) { // get tags $tags = YTable::getInstance('tag')->getAll($app->id, null, null, 'items DESC', null, $params->get('count', 10), true); if (count($tags)) { // init vars $min_count = $tags[count($tags) - 1]->items; $max_count = $tags[0]->items; $font_span = ($max_count - $min_count) / 100; $font_class_span = (self::MAX_FONT_WEIGHT - self::MIN_FONT_WEIGHT) / 100; $menu_item = $params->get('menu_item', 0); $itemid = $menu_item ? '&Itemid=' . $menu_item : ''; // attach font size, href foreach ($tags as $tag) { $tag->weight = $font_span ? round(self::MIN_FONT_WEIGHT + ($tag->items - $min_count) / $font_span * $font_class_span) : 1; $tag->href = $menu_item ? sprintf('index.php?option=com_zoo&task=tag&tag=%s&app_id=%d%s', $tag->name, $app->id, $itemid) : RouteHelper::getTagRoute($app->id, $tag->name); } self::orderTags($tags, $params->get('order')); return $tags; } return array(); }
public function tag() { // get request vars $page = YRequest::getInt('page', 1); $this->tag = YRequest::getString('tag', ''); // get params $params = $this->application->getParams('site'); $items_per_page = $params->get('config.items_per_page', 15); $this->item_order = $this->_getItemOrder($params->get('config.item_order')); // get categories and items $this->categories = $this->application->getCategoryTree(true); $this->items = YTable::getInstance('item')->getByTag($this->application->id, $this->tag, true, null, $this->item_order); // get item pagination $this->pagination = new YPagination('page', count($this->items), $page, $items_per_page); $this->pagination->setShowAll($items_per_page == 0); $this->pagination_link = RouteHelper::getTagRoute($this->application->id, $this->tag); // slice out items if (!$this->pagination->getShowAll()) { $this->items = array_slice($this->items, $this->pagination->limitStart(), $items_per_page); } // set alphaindex if ($params->get('template.show_alpha_index')) { $this->alpha_index = $this->_getAlphaindex(); } // create pathway $link = JRoute::_(RouteHelper::getTagRoute($this->application->id, $this->tag)); $this->pathway->addItem(JText::_('Tags') . ': ' . $this->tag, $link); // get 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('tag')->addTemplatePath($this->template->getPath())->setLayout('tag')->display(); }