SkyHiRider Posted February 27, 2014 Share Posted February 27, 2014 (edited) I need to add a unique class to each category name in the list - ideally the category id so that I can exchange the category name for an image using css. What do I need to add to this code to make it happen? <li {if isset($last) && $last == 'true'}class="last"{/if}> <a href="{$node.link}" {if isset($currentCategoryId) && ($node.id == $currentCategoryId)}class="selected"{/if} title="{$node.desc|escape:html:'UTF-8'}">{$node.name|escape:html:'UTF-8'}</a> {if $node.children|@count > 0} <ul> {foreach from=$node.children item=child name=categoryTreeBranch} {if isset($smarty.foreach.categoryTreeBranch) && $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> {/if} </li> Edited February 27, 2014 by SkyHiRider (see edit history) Link to comment Share on other sites More sharing options...
genata93 Posted February 28, 2014 Share Posted February 28, 2014 Hello, you can try putting category-(ID) class on each A element in the category box. For this to happen try with the following code: <li {if isset($last) && $last == 'true'}class="last"{/if}> <a href="{$node.link}" {if isset($currentCategoryId) && ($node.id == $currentCategoryId)}class="selected category-{$currentCategoryId}"{/if}{else}class="category-{$currentCategoryId}"{/else} title="{$node.desc|escape:html:'UTF-8'}">{$node.name|escape:html:'UTF-8'}</a> {if $node.children|@count > 0} <ul> {foreach from=$node.children item=child name=categoryTreeBranch} {if isset($smarty.foreach.categoryTreeBranch) && $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> {/if} </li> Since I haven't tested please backup your files first, before making changes. Link to comment Share on other sites More sharing options...
vekia Posted February 28, 2014 Share Posted February 28, 2014 it will not work as SkyHiRider wants instead of class="selected category-{$currentCategoryId}" use class="selected category-{$node.id}" 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now