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.

Categories-Navigation with active menus

June 19, 2011 12:09pm

Subscribe [3]
  • #1 / Jun 19, 2011 12:09pm

    Ralph Segert

    15 posts

    Hello,

    I built a EE-Site with a Navigation based on the Channel Categories Tag. And now I search a solution for the fowolling problem:

    If an user click on any navigation-button (example “Lösungen”), than should be this button in an active status, please look to my example graphic.

    The simple way is class=“aktiv”:

    <li><a href="#class=aktiv">Lösungen</a></li>

    But I don’t see a chance to input this in the navigation with the Channel Categories Tag. Or is there a solution?

    Please consider, my customer wish only few channels.

    The Navigation contains sub menus. I work with EE 2.1.3

    I hope for your help. Thanks 😊

  • #2 / Jun 19, 2011 12:58pm

    Ralph Segert

    15 posts

    Ok, I’ve found a little solution to highlight the current link (RTFM 😉:

    {if category_url_title==segment_2}class="aktiv"{/if}

    But now I have a new problem. If I click on any submenu-button in the drop down menu - example “Technische Dokumente” - than disappears the highlight link again.

    Is there a way to avert this? Thanks, I hope for your experience:-)

  • #3 / Jun 20, 2011 3:15am

    Hi Raplhs,
    Considering your url segment (segment_2) changes based on the category you selected the following code should work.

    {exp:query sql="SELECT parent_id from exp_categories where cat_url_title='{segment_2}'"}
        {if parent_id == "0"}
            {if category_url_title == segment_2}class="aktiv"{/if} 
        {if:else}
            {exp:query sql="SELECT cat_url_title from exp_categories where cat_id={parent_id}"}
                {if category_url_title == cat_url_title}class="aktiv"{/if}
            {/exp:query} 
        {/if}
    {/exp:query}

    I’m not sure if there’s a simple way to do this.

    Srikanth

  • #4 / Jun 20, 2011 10:08am

    Ralph Segert

    15 posts

    Thank you very much. This way doesn’t work. The submenus disappears.
    The simply code without “category_url_title==segment_2”:

    {exp:channel:categories channel="leistung" show_empty="no"}
    <a href="http://{path=leistung/{category_url_title}}">{category_name}</a>
    {/exp:channel:categories}
  • #5 / Jun 20, 2011 12:42pm

    John Henry Donovan

    12339 posts

    Ralphs,

    This is more of a How to question so moving to Community help for you.  You may need to adjust the syntax slightly with the following

    {exp:query sql="SELECT parent_id from exp_categories where cat_url_title='{segment_2}'"}
        {if parent_id == "0"}
            {if category_url_title == "{segment_2}"}class="aktiv"{/if} 
        {if:else}
            {exp:query sql="SELECT cat_url_title from exp_categories where cat_id='{parent_id}'"}
                {if category_url_title == "{cat_url_title}"}class="aktiv"{/if}
            {/exp:query} 
        {/if}
    {/exp:query}

    Other than that try Selected or CatMenu

  • #6 / Jun 20, 2011 12:53pm

    Thanks for the modification John. I missed it.

  • #7 / Jun 20, 2011 12:55pm

    John Henry Donovan

    12339 posts

    No problems Srikanth. Thanks for helping out. Hopefully it will for him now

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases