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.

problem with if conditional

November 18, 2011 4:59am

Subscribe [3]
  • #1 / Nov 18, 2011 4:59am

    Hi. I cant figure out what I am doing wrong here.

    I am trying to get the URL to change if segment_2 is ‘latest’

    <a href="{title_permalink='gallery/view'}/{if segment_2 == 'latest'}latest{if:else}{segment_4}{/if}">

    For some reason even if the segment_2 is ‘latest’ it doesn’t add /latest to the URL.

    Does my code look right?

    Thanks

  • #2 / Nov 18, 2011 2:56pm

    Barrel

    92 posts

    I think you’re missing brackets and ’ ’

    <a href="{title_permalink='gallery/view'}/{if '{segment_2}' == 'latest'}latest{if:else}{segment_4}{/if}">
  • #3 / Nov 21, 2011 3:04am

    John Henry Donovan

    12339 posts

    Hi Chris,

    That should work for you.

    What version and build of EE are you using?

    If you try this do you get a result

    Seg 2 : {segment_2}
    
    {if segment_2 == 'latest'}
    <a href="http://{title_permalink=gallery/view}/latest">link</a>
    {if:else}
    <a href="http://{title_permalink=gallery/view}">link</a>
    {/if}

    Can you provide some more of your template code please?

     

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

ExpressionEngine News!

#eecms, #events, #releases