Skins

Can I use the active category to generate a unique CSS class?

Scenario:
"I want to improve my site navigation by using CSS to style the link pointing to the current category differently (e.g. by having the link to the active category highlighted in a different color). Is there an easy way to use Nucleus to generate a unique CSS class based on the currently active category?"

Solution:
Use the new skin variable <%currentcat%> to generate your CSS class. This variable will return either a "yes" value if the current category is active or a "no" value if the category is not the currently active category.

In the "Category List Item" section of your template, put something like this in the html tag you are using to generate your category list (e.g. a li tag, etc):

class="currcat<%currentcat%>"


In your .css file, make sure you define the CSS classes .currcatyes (for the current active category) and .currcatno (for all other categories) as desired.

Original forum thread (thanks, ftruscot!):
http://nucleuscms.org/forum/viewtopic.php?t=18549
section: Skins | submitted by Leng on 2009.Mar.16 | 7441 views

item rate
Total votes: 11 - Rating: 10.00

Please tell us how useful this answer was to you (0 = useless, 10 = very very helpful):

10