0

我想從此模板http://ironsummitmedia.github.io/startbootstrap-modern-business/index.html中將導航菜單放到我的CMS製作簡單菜單模板中。對我來說,CMS Made Simple的一切都很容易實現,但必須使用代碼來創建動態菜單。這裏有一些代碼作爲起點。CMS製作簡單菜單

{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} 

這裏是我想生成導航:

<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> 

回答

0

我沒有看到父母的測試。你需要......

{if $node->parent == true} 

然後你就可以得到

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