I've browsed the questions and answers here and i can't find anything that works for what i'm trying to do!
I am using this as the main menu of my site (so it is in _layout.html)
{% nav category in craft.categories.group('artCats') %}
{% set entryCount = craft.entries.relatedTo(category).total()
<li><a href="{{ category.url }}"><span>{{ category.title }}</span>{% if category.level == 2 %}<span class="postnum">({{ entryCount }})</span>{% endif %}</a>
{% ifchildren %}
<ul>
{% children %}
</ul>
{% endifchildren %}
</li>
{% endnav %}
It's a drop down menu that shows how many posts are in each sub category. All works nicely!
However, no matter what i try, i can't seem to dynamically assign a class to the current page. I think i'm misunderstanding in general how this is done in Craft.
I see a lot of solutions that are basically saying "if url segment is "fishcake" then add my class" but to me, that's not dynamic at all! Dynamic would be if i add a new sub-category, the menu will add my desired class to that menu item if i visit, without me having to add a new if statement in the Twig code.
Am i able to do something like "if the category.url of this link matches the current url, do this" ?