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.

2 questions - category highlight and "this url"

November 20, 2014 9:44pm

Subscribe [2]
  • #1 / Nov 20, 2014 9:44pm

    andrew001

    136 posts

    So, I have 2 questions, hope someone can shed light on.

    1. is it possible to use a category loop for navigation, and highlight the active state?

    For example:

    {exp:channel:categories channel="article" show_empty="no" style="linear"}
      <li class="{if segment_2 == "category"}selected{/if}"><a href="http://{path=%27articles/index%27}" title="{category_name}">{category_name}</a></li>
    {/exp:channel:categories}

    Obviously the above is a fail, but you can get an idea of what I am trying to do. The only way I can figure how to pull this off is to hard code each entry. Which defeats the purpose of the loop.

    2. Is there a way or method to get the current url?

    Here is my situation, I have a newsletter signup form (freeform pro) in the footer of the page. this is an include (embed=embeds/.footer) - and I cannot get freeform pro to stay in one spot upon validation. it always jump to the top of the page. So I have added the from validation error at the top of the page, however, freeform requires a return page for errors. I’d like to keep the user on the same page.

    The line of code in question is:

    inline_error_return="home"

    Home needs to be like “current URL”

    Is this at all possible?

    Thanks

  • #2 / Nov 20, 2014 9:49pm

    andrew001

    136 posts

    it looks like: 

    {path='{segment_1}/{segment_2}/{segment_3}/{segment_4}/{segment_5}/{segment_6}'}

    works is current url. Ha!

  • #3 / Nov 21, 2014 11:30am

    Boyink!

    5011 posts

    I usually just do:

    <li {if segment_3==category_url_title}class="active_cat"{/if}>

    Adjust segment as necessary.

    There is also: {current_url} as a standard global variable.

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

ExpressionEngine News!

#eecms, #events, #releases