This question may be related to a resolved thread.
Hello,
The magazine site I’m developing has a single article-view template that displays a list of all the site-wide article categories (called “Article Topics”) in the sidebar. For the single article being displayed, it’s specific Article Topics need to be given an “active” or “current” CSS class in order to be highlighted. The issue I’m having now is: how can I conditionally add a class to a dynamically generated categories list without, again, being able to utilize url segments (these Article Topics—the article’s categories—don’t appear in the url)? Here’s the code I’m dealing with:
I need to have this…
<h5 class="articleTopics">Article Topics</h5>
{exp:channel:categories channel="journal|primer" style="nested" category_group="10" class="list1"}
<a href="http://{path=finelife-journal/show}">{category_name}</a>
{/exp:channel:categories}
...dynamically generate this HTML (note the “current” class on the second <li> denoting the article in question):
<h5 class="articleTopics">Article Topics</h5>
<ul class="list1">
<li><a href="#">economics</a></li>
<li class="current"><a href="#">business</a></li>
<li><a href="#">ecology</a></li>
...
</ul>I’m sure this involves the use of conditionals but I’m not sure where to place them. This is a case of knowing it can be done and just not knowing how.
Thanks.
-Gamiel