/** * Gets the path from root to child as breadcrumbs * * @param integer $id Category ID * @param string $separator Path separator * @param boolean $renderAsMicroData Renders breadcrumbs as HTML5 microdata * @param string $useCssClass Use CSS class "breadcrumb" * @return string */ public function getPath($id, $separator = ' / ', $renderAsMicroData = false, $useCssClass = 'breadcrumb') { global $sids; $ids = $this->getNodes($id); $num = count($ids); $temp = $catid = $desc = $breadcrumb = []; for ($i = 0; $i < $num; $i++) { $t = $this->getLineCategory($ids[$i]); if (array_key_exists($t, $this->treeTab)) { $temp[] = $this->treeTab[$this->getLineCategory($ids[$i])]['name']; $catid[] = $this->treeTab[$this->getLineCategory($ids[$i])]['id']; $desc[] = $this->treeTab[$this->getLineCategory($ids[$i])]['description']; } } if (isset($this->treeTab[$this->getLineCategory($id)]['name'])) { $temp[] = $this->treeTab[$this->getLineCategory($id)]['name']; $catid[] = $this->treeTab[$this->getLineCategory($id)]['id']; $desc[] = $this->treeTab[$this->getLineCategory($id)]['description']; } // @todo Maybe this should be done somewhere else ... if ($renderAsMicroData) { foreach ($temp as $k => $category) { $url = sprintf('%s?%saction=show&cat=%d', PMF_Link::getSystemRelativeUri(), $sids, $catid[$k]); $oLink = new PMF_Link($url, $this->_config); $oLink->text = sprintf('<span itemprop="title">%s</span>', $category); $oLink->itemTitle = $category; $oLink->tooltip = $desc[$k]; $oLink->setItemProperty('url'); if (0 == $k) { $oLink->setRelation('index'); } $breadcrumb[] = sprintf('<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb">%s</li>', $oLink->toHtmlAnchor()); } $temp = $breadcrumb; return sprintf('<ul class="%s">%s</ul>', $useCssClass, implode('', $temp)); } else { return implode($separator, $temp); } }