Example #1
0
 /**
  * Init and Generate the website's breadcrumb nav bar
  */
 private function generateBreadcrumb()
 {
     $this->breadcrumbMenus = collect();
     $this->addBreadcrumbLink('Home', '/', 'home');
     $prevTitle = 'Home';
     $navs = $this->selectedNavigation->getParentsAndYou();
     foreach ($navs as $k => $nav) {
         if ($nav->title != $prevTitle) {
             $url = is_slug_url($nav->slug) ? $nav->slug : url($this->baseUrl . $nav->url);
             $this->addBreadcrumbLink($nav->title, $url);
         }
         $prevTitle = $nav->title;
     }
 }
 /**
  * Recursive generate the menu for all the children of given $nav
  * @param $parent
  * @return string
  */
 private function generateNavigationChildren($parent)
 {
     $html = '';
     $navigation = NavigationWebsite::whereParentIdORM($parent->id);
     $html .= '<ul>';
     foreach ($navigation as $key => $nav) {
         $url = is_slug_url($nav->slug) ? $nav->slug : url($this->baseUrl . $nav->url);
         $children = NavigationWebsite::whereParentIdORM($nav->id);
         $html .= '<li>';
         $html .= '<a tabindex="-1" href="' . (count($children) > 0 ? '#' : $url) . '">' . $nav->title . '</a>';
         // if children
         if (count($children) > 0) {
             $html .= '<ul>';
         }
         foreach ($children as $c => $child) {
             $url = is_slug_url($child->slug) ? $child->slug : url($this->baseUrl . $child->url);
             $html .= '<li><a tabindex="-1" href="' . $url . '">' . $child->title . '</a></li>';
         }
         // if children
         if (count($children) > 0) {
             $html .= '</ul>';
         }
         $html .= '</li>';
     }
     $html .= '</ul>';
     return count($navigation) > 0 ? $html : '';
 }