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));
         }
     }
 }
 /**
  * Create a navigation item for a metamodel item
  * @param CreateItemEvent $event
  */
 public function createItem(CreateItemEvent $event)
 {
     $item = $event->getItem();
     $name = $item->getName();
     if ($item->getType() != 'metamodels') {
         return;
     }
     $model = $this->loadModel($name);
     if (!$model) {
         return;
     }
     $value = $model->parseValue('text', $this->renderSetting);
     $uri = $value['jumpTo']['url'];
     $item->setLabel($this->generateLabel($model))->setExtra('model', $model)->setExtra('value', $value)->setExtra('provider', $this->providerId)->setUri($uri);
     if ($value['class']) {
         $item->setLabelAttribute('class', $value['class']);
     }
     $this->renderAttributeMapping($item, $value);
     if ($uri == \Environment::get('request')) {
         $item->setCurrent(true);
         $item->getParent()->setTrail(true)->setCurrent(false);
     }
 }
 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());
                     }
                 }
             }
         }
     }
 }