Example #1
0
 /**
  * @param $observer
  * @return $this
  */
 public function execute(EventObserver $observer)
 {
     $menu = $observer->getMenu();
     $tree = $menu->getTree();
     $fullAction = $this->request->getFullActionName();
     $selectedActions = ['gemtoo_blog_article_index', 'gemtoo_blog_article_view'];
     $articleNodeId = 'articles';
     $data = ['name' => __('Blog'), 'id' => $articleNodeId, 'url' => $this->articleUrl->getListUrl(), 'is_active' => in_array($fullAction, $selectedActions)];
     $articlesNode = new Node($data, 'id', $tree, $menu);
     $menu->addChild($articlesNode);
     return $this;
 }
 /**
  * Page block html topmenu gethtml before
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if (!$this->_scopeConfig->isSetFlag(static::XML_PATH_TOP_MENU_SHOW_ITEM, \Magento\Store\Model\ScopeInterface::SCOPE_STORE)) {
         return;
     }
     /** @var \Magento\Framework\Data\Tree\Node $menu */
     $menu = $observer->getMenu();
     $block = $observer->getBlock();
     $tree = $menu->getTree();
     $data = ['name' => $this->_scopeConfig->getValue(static::XML_PATH_TOP_MENU_ITEM_TEXT, \Magento\Store\Model\ScopeInterface::SCOPE_STORE), 'id' => 'magefan-blog', 'url' => $this->_url->getBaseUrl(), 'is_active' => $block->getRequest()->getModuleName() == 'blog'];
     $node = new Node($data, 'id', $tree, $menu);
     $menu->addChild($node);
 }
Example #3
0
 /**
  * @param $observer
  * @return $this
  */
 public function execute(EventObserver $observer)
 {
     /** @var \Magento\Framework\Data\Tree\Node $menu */
     $menu = $observer->getMenu();
     $tree = $menu->getTree();
     $fullAction = $this->request->getFullActionName();
     $selectedActions = ['sample_news_author_index', 'sample_news_author_view'];
     $authorNodeId = 'authors';
     $data = ['name' => __('Authors'), 'id' => $authorNodeId, 'url' => $this->authorUrl->getListUrl(), 'is_active' => in_array($fullAction, $selectedActions)];
     $authorsNode = new Node($data, 'id', $tree, $menu);
     $menu->addChild($authorsNode);
     return $this;
 }
Example #4
0
 /**
  * Adds catalog categories to top menu
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function addCatalogToTopmenuItems(\Magento\Framework\Event\Observer $observer)
 {
     $block = $observer->getEvent()->getBlock();
     $block->addIdentity(\Magento\Catalog\Model\Category::CACHE_TAG);
     $this->_addCategoriesToMenu($this->_catalogCategory->getStoreCategories(), $observer->getMenu(), $block);
 }
Example #5
0
 public function addTestimonialToTopmenuItems(\Magento\Framework\Event\Observer $observer)
 {
     $block = $observer->getEvent()->getBlock();
     $block->addIdentity('testimonial');
     $this->_addTestimonialMenu('testimonial', $observer->getMenu(), $block);
 }