Jump to content

[SOLVED] Add a ID to each category


need4speed

Recommended Posts

Im not skilled PHP programmer.

So I hope somebody can help me with my request.

I want to add a ID tag to each category How can I do that?

So I can style each category with CSS.


This is the default code for the "blockcategories" module

>

{$node.name|escape:html:'UTF-8'}
   {if $node.children|@count > 0}
</pre>
<ul>
       {foreach from=$node.children item=child name=categoryTreeBranch}
           {if $smarty.foreach.categoryTreeBranch.last}
                       {include file=$branche_tpl_path node=$child last='true'}
           {else}
                       {include file=$branche_tpl_path node=$child last='false'}
           {/if}
       {/foreach}
</ul>
<br>   {/if}<br><br><br

Link to comment
Share on other sites

Try:

>

   <a href="{$node.link|escape:html:'UTF-8'}"class="selected" title="{$node.desc|escape:html:'UTF-8'}">{$node.name|escape:html:'UTF-8'}
   {if $node.children|@count > 0}
</pre>
<ul>
       {foreach from=$node.children item=child name=categoryTreeBranch}
           {if $smarty.foreach.categoryTreeBranch.last}
                       {include file=$branche_tpl_path node=$child last='true'}
           {else}
                       {include file=$branche_tpl_path node=$child last='false'}
           {/if}
       {/foreach}
</ul>
<br>   {/if}<br



Then you can use #cat2, #cat3, etc.

Link to comment
Share on other sites

No, I think the bug was in PrestaShop v1.2.5. So the same IDs are appearing more than once? The $node variable should change with each recursion, causing a different ID to be displayed. I use this code in my category modules without any problems.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...