21/09/2015, 12:40:33
Est-ce que le code de ton 2ème menu (online), celui qui fonctionne, est le bon ? Il y a de nouveau des différences entre lui et celui que tu m'avais demandé.
Voilà le code qui reflète exactement ton second menu online :
Voilà le code qui reflète exactement ton second menu online :
Code :
{* 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}
{$caret='<b class="caret"></b>'}
{if $depth == 0}
<div id="navbar" class="navbar-collapse collapse">
<ul class='nav navbar-nav navbar-right' role='menu'>
{else}
<ul class='dropdown-menu'>
{/if}
{$depth=$depth+1}
{foreach $nodes as $node}
{* création et reset classes liens et ancres *}
{$liclass=[]}
{$aclass=[]}
{if $depth == 1}{* si on est sur le top parent *}
{$liclass[]='dropdown'}
{$liclass[]='active'}
{$aclass[]='dropdown-toogle'}
{* $aclass[]=$node->alias *}{* à dé-commenter si alias dans la classe de l'ancre *}
{elseif $node->children_exist}{* si l'item a des enfants *}
{$liclass[]='dropdown'}
{$liclass[]='dropdown-submenu'}
{$aclass[]='dropdown-toogle'}
{* {$aclass[]=$node->alias} *}{* à dé-commenter si alias dans la classe de l'ancre *}
{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 $depth == 1}
<li class="{implode(' ',$liclass)}">
<a{if count($aclass) > 0} class="{implode(' ',$aclass)}"{/if} href="#" data-toggle='dropdown' data-target='#'>{$node->menutext} {$caret}</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>
{else}
<li{if count($liclass) > 0} class="{implode(' ',$liclass)}"{/if}>
<a{if count($aclass) > 0} class="{implode(' ',$aclass)}"{if $node->children_exist} data-toggle='dropdown'{/if}{/if} href="#{if !$node->children_exist}{$node->alias}{/if}">{$node->menutext}</a>
{if isset($node->children)}
{include file=$smarty.template nodes=$node->children}
{/if}
</li>
{/if}
{/foreach}
{$depth=$depth-1}
</ul>
{/strip}