public function createItem(CreateItemEvent $event) { $item = $event->getItem(); if ($item->getType() == 'article') { $article = \ArticleModel::findByPk($item->getName()); if ($article) { $page = \PageModel::findByPk($article->pid); if ($page) { $cssID = deserialize($article->cssID, true); $item->setUri(\Frontend::generateFrontendUrl($page->row()) . '#' . (empty($cssID[0]) ? $article->alias : $cssID[0])); $item->setLabel($article->title); $item->setExtras($article->row()); } } } }
public function createItem(CreateItemEvent $event) { $item = $event->getItem(); if ($item->getType() == 'page') { $page = \PageModel::findByPk($item->getName()); if ($page) { if ($page->type == 'redirect') { $uri = $page->url; $uri = html_entity_decode($uri, ENT_QUOTES, 'UTF-8'); $uri = $this->replaceInsertTags($uri); } else { $uri = \Frontend::generateFrontendUrl($page->row()); } $item->setUri($uri); $item->setLabel($page->title); if ($page->cssClass) { $class = $item->getAttribute('class', ''); $item->setAttribute('class', trim($class . ' ' . $page->cssClass)); $class = $item->getLinkAttribute('class', ''); $item->setLinkAttribute('class', trim($class . ' ' . $page->cssClass)); $class = $item->getLabelAttribute('class', ''); $item->setLabelAttribute('class', trim($class . ' ' . $page->cssClass)); } if ($page->xnavigationLightbox) { $item->setLinkAttribute('data-lightbox', 'page-' . $page->id); if ($page->xnavigationLightboxWidth) { $item->setLinkAttribute('data-lightbox-width', $page->xnavigationLightboxWidth); } if ($page->xnavigationLightboxHeight) { $item->setLinkAttribute('data-lightbox-height', $page->xnavigationLightboxHeight); } } $currentPage = $this->getCurrentPage(); $item->setExtras($page->row()); $item->setCurrent($currentPage->id == $page->id); $item->setTrail(in_array($page->id, $currentPage->trail)); } } }
public function createItem(CreateItemEvent $event) { $item = $event->getItem(); if ($item->getType() == 'content') { $content = \ContentModel::findByPk($item->getName()); if ($content && ($content->ptable == '' || $content->ptable == 'tl_article')) { $article = \ArticleModel::findByPk($content->pid); if ($article) { $page = \PageModel::findByPk($article->pid); if ($page) { $headline = deserialize($content->headline, true); $cssID = deserialize($content->cssID, true); if (!empty($headline['value']) && !empty($headline['unit']) && !empty($cssID[0])) { $item->setUri(\Frontend::generateFrontendUrl($page->row()) . '#' . $cssID[0]); $item->setLabel($headline['value']); $item->setExtras($content->row()); } } } } } }