Jump to content

How To Get Primary Menu Without Class


jawanet

Recommended Posts

Hi

 

I want to just get the primaryNav, if you know how to combine them please help me.

 

{foreach $navbar as $item}
   <li menuItemName="{$item->getName()}"{if $item->hasChildren()} class="dropdown top-menu-item-xs"{elseif $item->getClass()} class="dropdown top-menu-item-xs {$item->getClass()}"{/if} id="{$item->getId()}">
       <a {if $item->hasChildren()}class="dropdown-toggle" data-toggle="dropdown" href="#"{else}href="{$item->getUri()}"{/if}{if $item->getAttribute('target')} target="{$item->getAttribute('target')}"{/if}>
           {if $item->hasIcon()}<i class="{$item->getIcon()}"></i> {/if}
           <i class="fa fa-user"></i> <span class="hidden-xs">{$item->getLabel()}</span>
           {if $item->hasBadge()} <span class="badge">{$item->getBadge()}</span>{/if}
           {if $item->hasChildren()} <b class="caret"></b>{/if}
       </a>
       {if $item->hasChildren()}
           <ul class="dropdown-menu">
           {foreach $item->getChildren() as $childItem}
               <li menuItemName="{$childItem->getName()}"{if $childItem->getClass()} class="{$childItem->getClass()}"{/if} id="{$childItem->getId()}">
                   <a href="{$childItem->getUri()}"{if $childItem->getAttribute('target')} target="{$childItem->getAttribute('target')}"{/if}>
                       {if $childItem->hasIcon()}<i class="{$childItem->getIcon()}"></i> {/if}
                       {$childItem->getLabel()}
                       {if $childItem->hasBadge()} <span class="badge">{$childItem->getBadge()}</span>{/if}
                   </a>
               </li>
           {/foreach}
           </ul>
       {/if}
   </li>
{/foreach}

Edited by jawanet
Link to comment
Share on other sites

you will not be able to identify it from this file by default, then you need to make small modification in header.tpl file first

 

in the navbar include command I'm going to add extra parameter, I will call it "layout":

               <ul class="nav navbar-nav">

                   {include file="$template/includes/navbar.tpl" navbar=$primaryNavbar layout="primary"}

               </ul>

               <ul class="nav navbar-nav navbar-right">

                   {include file="$template/includes/navbar.tpl" navbar=$secondaryNavbar layout="secondary"}

               </ul>

 

now in /templates/{Template-Name}/includes/navbar.tpl I will check the "layout" value and display related syntax:

{if $layout eq "primary"}
// display primary navbar here
{else}
// display secondary navbar here
{foreach $navbar as $item}
   <li menuItemName="{$item->getName()}"{if $item->hasChildren()} class="dropdown"{elseif $item->getClass()} class="{$item->getClass()}"{/if} id="{$item->getId()}">
       <a {if $item->hasChildren()}class="dropdown-toggle" data-toggle="dropdown" href="#"{else}href="{$item->getUri()}"{/if}{if $item->getAttribute('target')} target="{$item->getAttribute('target')}"{/if}>
           {if $item->hasIcon()}<i class="{$item->getIcon()}"></i> {/if}
           {$item->getLabel()}
           {if $item->hasBadge()} <span class="badge">{$item->getBadge()}</span>{/if}
           {if $item->hasChildren()} <b class="caret"></b>{/if}
       </a>
       {if $item->hasChildren()}
           <ul class="dropdown-menu">
           {foreach $item->getChildren() as $childItem}
               <li menuItemName="{$childItem->getName()}"{if $childItem->getClass()} class="{$childItem->getClass()}"{/if} id="{$childItem->getId()}">
                   <a href="{$childItem->getUri()}"{if $childItem->getAttribute('target')} target="{$childItem->getAttribute('target')}"{/if}>
                       {if $childItem->hasIcon()}<i class="{$childItem->getIcon()}"></i> {/if}
                       {$childItem->getLabel()}
                       {if $childItem->hasBadge()} <span class="badge">{$childItem->getBadge()}</span>{/if}
                   </a>
               </li>
           {/foreach}
           </ul>
       {/if}
   </li>
{/foreach}

{/if}

 

another solution is to use separate file for each navbar, this will require the same modification in header.tpl file only:

 

               <ul class="nav navbar-nav">

                   {include file="$template/includes/navbar-primary.tpl" navbar=$primaryNavbar}

               </ul>

               <ul class="nav navbar-nav navbar-right">

                   {include file="$template/includes/navbar-secondary.tpl" navbar=$secondaryNavbar}

               </ul>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated