ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Highlight current category in nav when on single entry page

July 07, 2010 11:23am

Subscribe [2]
  • #1 / Jul 07, 2010 11:23am

    Mikee Bee

    179 posts

    Hi all, I can do this when the category is part of the url but when I’m on a single entry page I’m stumped!

    This is what I use on a category page (when the category is present in the nav)...

    <li{if "{category_url_title}" == "{segment_3}"} class="current"{/if}><a href="#}">{category_name}</a></li>

    Many thanks

    Mikee

  • #2 / Jul 09, 2010 11:01am

    Wouter Vervloet

    758 posts

    Hi Mikee,

    How about this?

    {if {category_url_title} == '{segment_3}'}
    <li class="current">{category_name}</li>
    {if:else}
      <li><a href="#">{category_name}</a></li>
    {/if}

    just keeping it simple…

    Greetz,
    Wouter

  • #3 / Jul 09, 2010 11:21am

    Mikee Bee

    179 posts

    But I need the class of current on the list item when the {category_url_title} isn’t in the url. Basically still highlighting the navigation item without the category segment… I suppose I could tack the {category_url_title} to the end of the url? But I thought there would be a better way.

    This is what I have…

    <ul class="section-nav">
    {exp:channel:categories style="linear" channel="blog"}
    <li{if "{category_url_title}" == "{segment_3}"} class="current"{/if}><a href="http://{path=">{category_name}</a></li>
    {/exp:channel:categories}
    </ul>
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases