Jump to content
xt:Commerce Community Forum

Horizontales Menü in box_topcategories


fepol

Recommended Posts

Hallo Zusammen,

Ich bin gerade dabei ein Horizontales Menü in der box_topcategories zu erstellen.

Leider habe ich anscheinend irgendwo einen Fehler gemacht :/

Wenn mir jemand helfen würde, wäre super :D

 

Meine box_topcategories.html :

<div id="box-topcategories">
	{if $_categories}
   	{php}
    	$level_1tmp=0;
        $level_2tmp=0;
    {/php} 
	<ul>     
		{foreach name=aussen item=module_data from=$_categories}
        	{if $module_data.level==1}
				{if $level_2tmp==2}
                	</ul>
                    {php}
                	$levle_2tmp=0;
      	            {/php}
                {/if}
                {if $level_1tmp==1}
                	</li>
                {/if}
                <li id="box-topcategories-categorie-{$module_data.categories_id}" class="level{$module_data.level}{if $module_data.active} active{/if}"><a href="{$module_data.categories_link}">{$module_data.categories_name}</a>
                {if $level_1tmp==0}
               		{php}
                		$level_1tmp=1;
                	{/php}
                {/if}
                {if $level_1tmp==2}
               		{php}
                		$level_1tmp=1;
                	{/php}
                {/if}
            {/if}
            {if $module_data.level==2}
       			{php}
                	$level_1tmp=2;
                {/php}
            	{if $level_2tmp==0}
                	<ul>
                    {php}
                    $level_2tmp=1;
                    {/php}
                {/if}    
                <li id="box-topcategories-categorie-{$module_data.categories_id}" class="level{$module_data.level}{if $module_data.active} active{/if}"><a href="{$module_data.categories_link}">{$module_data.categories_name}</a></li>                       
            {/if}
        {/foreach}
	</ul>
	{/if}
</div><!-- #box-topcategories -->

Und dann das Ergebnis:

<div id="box-topcategories">
	   	 
	<ul>     
		<li id="box-topcategories-categorie-1" class="level1 active"><a href="...">...</a>
		    <ul>
                <li id="box-topcategories-categorie-5" class="level2"><a href="...">...</a></li>                       
                	<ul>
                        <li id="box-topcategories-categorie-6" class="level2"><a href="...">...</a></li>                       
                        <ul>
                            <li id="box-topcategories-categorie-7" class="level2"><a href="...">...</a></li>                       
                            <li id="box-topcategories-categorie-2" class="level1"><a href="...">...</a>
                            <li id="box-topcategories-categorie-3" class="level1"><a href="...">...</a>
                            <li id="box-topcategories-categorie-4" class="level1"><a href="...">...</a>
                        </ul>
	</div><!-- #box-topcategories -->

Aussehen soll es aber so:

<div id="box-topcategories">
	   	 
	<ul>     
		<li id="box-topcategories-categorie-1" class="level1 active"><a href="...">...</a>
		    <ul>
                <li id="box-topcategories-categorie-5" class="level2"><a href="...">...</a></li>
                <li id="box-topcategories-categorie-6" class="level2"><a href="...">...</a></li>
                <li id="box-topcategories-categorie-7" class="level2"><a href="...">...</a></li>
            </ul>
        <li id="box-topcategories-categorie-2" class="level1"><a href="...">...</a></li>
        <li id="box-topcategories-categorie-3" class="level1"><a href="...">...</a></li>
        <li id="box-topcategories-categorie-4" class="level1"><a href="...">...</a></li>
    </ul>
</div><!-- #box-topcategories -->

UPDATE:

Hab es hinbekommen, so funktioniert es:

<div id="box-topcategories">
	{if $_categories}
   	{php}
    	$level_1tmp=0;
        $level_2tmp=0;
    {/php} 
	<ul>     
		{foreach name=aussen item=module_data from=$_categories}
        	{if $module_data.level==1}
            	{php}
                	if($level_2tmp==1){
                        echo "</ul>";
                        $level_2tmp=0;
                    }
                    if($level_1tmp==1){
                        echo "</li>";
                    }
            	{/php}
                <li id="box-topcategories-categorie-{$module_data.categories_id}" class="level{$module_data.level}{if $module_data.active} active{/if}"><a href="{$module_data.categories_link}">{$module_data.categories_name}</a>           
                {php}
                	if($level_1tmp==0 || $level_1tmp==2){
                        $level_1tmp=1;
                    }
                {/php} 
            {/if}
			{if $module_data.level==2}
            	{php}
					$level_1tmp=2;
					if($level_2tmp==0){
						echo "<ul>";
						$level_2tmp=1;
					}
                {/php}
				<li id="box-topcategories-categorie-{$module_data.categories_id}" class="level{$module_data.level}{if $module_data.active} active{/if}"><a href="{$module_data.categories_link}">{$module_data.categories_name}</a></li>
        	{/if}
        {/foreach}
	</ul>
	{/if}
</div><!-- #box-topcategories -->

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
  • Create New...