I have several navigation links that have sub pages, blog being one of them, and it’s easy to determine if I’m currently viewing a blog entry because “blog” exists in the URL. For example…
<a href="/blog/" class="expandable {if segment_1 == ">Blog</a>But for my static pages (not using the Pages module) and blog entries I don’t know how to determine which category the currently viewed entry is in? I have this at the top of my templates…
{if segment_2 != ""}
{exp:weblog:entries weblog="{my_weblog}" orderby="date" dynamic="on" sort="desc" limit="1" url_title="{segment_2}"}
{assign_variable:view="single"}
{assign_variable:page_title="{title}"}
{assign_variable:current_category="{category}"}
{/exp:weblog:entries}
{/if}You can see that if segment_2 isn’t blank, then I’m viewing a single entry, and I’m changing my layout a bit further down the page, and setting the page title, but the current_category isn’t being assigned, it’s just printing {category} on the page. Ideally I’d like my navigation code to look like this…
<a href="/blog/" class="expandable {if current_category == ">Link to this category of entries</a>or
<a href="/page/about/" class="expandable {if current_category == ">About</a>Does that make sense?