All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Simple navigation with Low Variables

thomassausen 14 Mar 2012 23:44 question, complete

Hi,

I'm a Low-newbie and want to have a simple navigation done with Low Variables. Because it's a better way for managing navigation for clients I think.

Everything is working fine, but I don't know how to achieve a current class. I just want to highlight the current active nav-element.

Any ideas?

Replies

  1. Low 15 Mar 2012 08:33

    Hi Thomas,

    In your conditional, you need to know what you're testing against. Your example says {if active == "y"}, which implies {active} to be a variable that could have the value "y". But in the low_variables:parse tag, no {active} variable is available.

    This means you have to test against something else. For example, you could check the {value} var against {segment_1}, so:

    {if segment_1 == value} class="current"{/if}


    ...or something like that.

  2. thomassausen 15 Mar 2012 08:48

    I tried it that way and nothing changed.

    The class was'nt rendered.

    The same code hardcoded without LV is working fine.

  3. Low 15 Mar 2012 08:49

    Okay, then what exactly is {value} outputting for each of the items?

  4. thomassausen 15 Mar 2012 08:53

    Variable Name: tsdv1_site_menu
    Variable Type: Select
    Options: / : Home
    portfolio : Portfolio
    contact : Contact

    Allow for multiple items to be selected: checked.

  5. Low 15 Mar 2012 09:03

    Is the conditional working for the portfolio and contact pages?

  6. thomassausen 15 Mar 2012 09:04

    No.

  7. Low 15 Mar 2012 09:06

    Then I cannot reproduce. For me, the conditional is working fine with the code example above.

    Can you give me super admin access to your installation, so I can take a look myself? You can send the login credentials to hi at gotolow dot com.

  8. Low 15 Mar 2012 10:06

    Hi Thomas,

    This is what you had in your template:

    {if segment_1 == "value"} ... {/if}


    In this case, the conditional will look for the literal string "value" instead of the variable {value}. Changing it to...

    {if segment_1 == value} ... {/if}


    ...without the quotes works as expected. I've made another change to the conditional to account for the first item, where the value is '/':

    {if segment_1 == value OR (segment_1 == '' AND value == '/')} ... {/if}


    ...so it works for the homepage, too.

  9. thomassausen 15 Mar 2012 10:21

    My fault. Thanks a lot. Great.