21/09/2015, 11:39:17
Ok, chef, j'ai trouvé l'erreur, il fallait utiliser $node->children_exist au lieu de $node->has_children et ne pas se gourer bêtement avec if depth = 1 au lieu de if depth == 1
Essaye ceci, je pense qu'on y est :
Essaye ceci, je pense qu'on y est :
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}
{$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' role='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}{* supprimer si pas d'alias dans la classe de l'ancre *}
{elseif $node->children_exist}{* si l'item a des enfants *}
{$liclass[]='dropdown'}
{$liclass[]='dropdown-submenu'}
{$aclass[]='dropdown'}
{$aclass[]='dropdown-toogle'}
{$aclass[]=$node->alias}{* supprimer si pas d'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="{$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>
{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} 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}