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.

Creating the ON state on dynamic pages.

May 24, 2009 11:24pm

Subscribe [3]
  • #1 / May 24, 2009 11:24pm

    topchi

    17 posts

    Hey guys,
    I ran into a dead end here…
    When I create a navigation I usually use this code to create a “on” state when the user is on that page

    {if "{embed:page}" == "home"}on{if:else}{/if}

    This time around all the on states are on the same page… the user simply navigates from one option to another without leaving that page.
    is there a techique i can use that can create the on state via URL
    for example if the url is this http://www.mysite.com/management_team_detail/mr.name_1

    can EE do something like

    {if "{url}" == "mr.name_1"}on{if:else}{/if}

    Thanks alot!
    Topchi

  • #2 / May 25, 2009 4:06am

    Ingmar

    29245 posts

    Yes, you can use something like

    {if segment_3 == "mr.name_1"}on{/if}

    Are there any reasons why you’d use an empty else clause? Also, as a rule, you should not quote your variables. Moving to Howto.

  • #3 / May 25, 2009 4:29am

    topchi

    17 posts

    Yes, you can use something like

    {if segment_3 == "mr.name_1"}on{/if}

    Are there any reasons why you’d use an empty else clause? Also, as a rule, you should not quote your variables. Moving to Howto.

    Hi Ingmar,
    Thanks for the “else if” advice.

    Need to rework the original concept a bit…
    if I use

    {if segment_3 == "mr.name_1"}on{/if}

    all the links appear as on on that page because the nav is generated by the CMS
    can i rework that so that it works with the {title} tag, since the title is the name of the guy only that particular link will be on… something like

    {if segment_3 == "title"}on{/if}

    Let me know and thanks!

    Btw where can I read about all of this, I went through the user guide with no luck :(

  • #4 / May 25, 2009 8:31am

    e-man

    1816 posts

    Btw where can I read about all of this, I went through the user guide with no luck :(

    URL Segment variables: http://expressionengine.com/docs/templates/globals/url_segments.html
    Conditional global variables: http://expressionengine.com/docs/templates/globals/conditionals.html

  • #5 / May 25, 2009 9:01am

    topchi

    17 posts

    Btw where can I read about all of this, I went through the user guide with no luck :(

    URL Segment variables: http://expressionengine.com/docs/templates/globals/url_segments.html
    Conditional global variables: http://expressionengine.com/docs/templates/globals/conditionals.html

    hmmm thank you for the note I did read up on it but cant get it to work

    lets say segment_3 is Topchi_Web_Newb
    and the title is Topchi Web Newb

    how do i get the 2 to match?
    and also is the use the “title” correct in the code below?

    class="{if segment_3 == title}on{/if}"
  • #6 / May 25, 2009 9:13am

    e-man

    1816 posts

    Title won’t work here, this should work though:

    {if segment_3 == url_title}class="on"{/if}

    note: this will have to be between exp:weblog:entries tag or it won’t pick up the variable {url_title}

  • #7 / May 26, 2009 12:02am

    topchi

    17 posts

    Worked like a charm! Thank you very much for your help. I really should take a week off and read everything EE, if only the psycho clients would let me. 😊
    Thanks again!
    Topchi

  • #8 / May 26, 2009 7:50am

    e-man

    1816 posts

    If you need some accelerated learning then these screencasts are highly recommended:

    http://www.pragprog.com/screencasts/v-riexp/building-a-dynamic-website-with-expressionengine

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

ExpressionEngine News!

#eecms, #events, #releases