18/09/2015, 19:40:11
Code :
{* cssmenu *}
{* this template uses recursion, but not a smarty function. *}
{*
variables:
node: contains the current node.
aclass: is used to build a string containing class names given to the a tag if one is used
liclass: is used to build a string containing class names given to the li tag.
*}
{if !isset($depth)}{$depth=0}{/if}
{strip}
{if $depth == 0}
<div id="navbar" class="navbar-collapse collapse">
<ul class='nav navbar-nav navbar-right' role='menu'>
{$caret='<b class="caret"></b>'}
{else}
<ul class='dropdown-menu' role='menu'>
{/if}
{$depth=$depth+1}
{foreach $nodes as $node}
{* setup classes for the anchor and list item *}
{$liclass=[]}
{$aclass=[]}
{if $node->index == 0}
{$liclass[]='dropdown'}
{$liclass[]='active'}
{$aclass[]='dropdown-toogle'}
{$aclass[]=$node->alias}
{elseif $node->has_children}
{$liclass[]='dropdown-submenu'}
{$aclass[]='dropdown'}
{$aclass[]=$node->alias}
{else}
{$aclass[]='scrollTo'}
{/if}
{* build the menu item from the node *}
{if $node->type == 'sectionheader'}
<li class='{implode(' ',$liclass)}'><a{if count($aclass) > 0} class="{implode(' ',$aclass)}"{/if}><span class="sectionheader">{$node->menutext}</span></a>
{if isset($node->children)}
{include file=$smarty.template nodes=$node->children}
{/if}
</li>
{elseif $node->type == 'separator'}
<li style="list-style-type: none;"><hr class="menu_separator"/></li>
{elseif $node->index == 0}
<li class="{implode(' ',$liclass)}">
<a{if count($aclass) > 0} class="{implode(' ',$aclass)}"{/if} href="{$node->url}" data-toggle='dropdown' data-target='#' target='_self'>{$node->menutext} {$caret}</a>
{if isset($node->children)}
{include file=$smarty.template nodes=$node->children}
{/if}
</li>
{else}
<li{if count($liclass) > 0} class="{implode(' ',$liclass)}"{/if}>
<a{if count($aclass) > 0} class="{implode(' ',$aclass)}"{/if} href="#{$node->alias}">{$node->menutext}</a>
{if isset($node->children)}
{include file=$smarty.template nodes=$node->children}
{/if}
</li>
{/if}
{/foreach}
{$depth=$depth-1}
</ul>
{if $depth == 0}
</div>{* menuwrapper *}
{/if}
{/strip}
Je ne l'ai pas testé, n'ayant pas de bootstrap sous la main.
Je n'ai pas fait le code pour le sectioneader ni pour le separator. Si tu en as besoin, je crois que tu n'auras pas de difficulté pour l'adapter.
[edit]Remplacé $node@first par $node->index == 0[/edit]