CMS Made Simple Menu

976 Views Asked by At

I would like to take the navigation menu from this template http://ironsummitmedia.github.io/startbootstrap-modern-business/index.html and put it in my CMS Made Simple Menu Template. To me everything about CMS Made Simple is easy to implement but the code one has to use for creating dynamic menus. Here is some code I have for as a starting point.

{strip}
{if $count > 0}
<ul class="nav navbar-nav navbar-right">
{foreach from=$nodelist item=node}
{if $node->depth > $node->prevdepth}
{repeat string="<ul class='dropdown'>" times=$node->depth-$node->prevdepth}
{elseif $node->depth < $node->prevdepth}
{repeat string="</li></ul>" times=$node->prevdepth-$node->depth}
</li>
{elseif $node->index > 0}</li>
{/if}

{if $node->current == true}
<li><a href="{$node->url}" class="active" {if $node->target ne ""} target="{$node->target}"{/if}> {$node->menutext} </a>

{elseif $node->type == 'sectionheader'}
<li>{$node->menutext}

{elseif $node->type == 'separator'}
<li> <hr class="separator" />

{else}
<li><a href="{$node->url}"{if $node->target ne ""} target="{$node->target}"{/if}> {$node->menutext} </a>

{/if}

{/foreach}

{repeat string="</li></ul>" times=$node->depth-1}</li></ul>
{/if}
{/strip}

And here is the navigation I am trying to generate:

<ul class="nav navbar-nav navbar-right">
<li>
    <a href="about.html">About</a>
</li>
<li>
    <a href="services.html">Services</a>
</li>
<li>
    <a href="contact.html">Contact</a>
</li>
<li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Portfolio <b class="caret"></b></a>
    <ul class="dropdown-menu">
        <li>
            <a href="portfolio-1-col.html">1 Column Portfolio</a>
        </li>
        <li>
            <a href="portfolio-2-col.html">2 Column Portfolio</a>
        </li>
        <li>
            <a href="portfolio-3-col.html">3 Column Portfolio</a>
        </li>
        <li>
            <a href="portfolio-4-col.html">4 Column Portfolio</a>
        </li>
        <li>
            <a href="portfolio-item.html">Single Portfolio Item</a>
        </li>
    </ul>
</li>
<li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Blog <b class="caret"></b></a>
    <ul class="dropdown-menu">
        <li>
            <a href="blog-home-1.html">Blog Home 1</a>
        </li>
        <li>
            <a href="blog-home-2.html">Blog Home 2</a>
        </li>
        <li>
            <a href="blog-post.html">Blog Post</a>
        </li>
    </ul>
</li>
<li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Other Pages <b class="caret"></b></a>
    <ul class="dropdown-menu">
        <li>
            <a href="full-width.html">Full Width Page</a>
        </li>
        <li>
            <a href="sidebar.html">Sidebar Page</a>
        </li>
        <li>
            <a href="faq.html">FAQ</a>
        </li>
        <li>
            <a href="404.html">404</a>
        </li>
        <li>
            <a href="pricing.html">Pricing Table</a>
        </li>
    </ul>
</li>
</ul>
1

There are 1 best solutions below

0
dmgd On

I don't see a test for parent. You need...

   {if $node->parent == true}

Then you can get

<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{$node->menutext} <b class="caret"></b></a>