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.

Conditional Comparing {current_path} and {page_uri}

June 11, 2014 2:10pm

Subscribe [1]
  • #1 / Jun 11, 2014 2:10pm

    I set up the following simple template:

    {exp:channel:entries channel="industries" require_entry="true" limit="1"}
    <pre>
    
    current_path = {current_path}
    page_uri     = {page_uri}
    
    ----
    
    Check current_path:
    
    {if "{current_path}" == "industry/government/test"}
    TRUE
    {if:else}
    FALSE
    {/if}
    
    ----
    
    Check page_uri:
    
    {if "{page_uri}" == "/industry/government/test"}
    TRUE
    {if:else}
    FALSE
    {/if}
    
    </pre>
    <p>{/exp:channel:entries}
    </pre>

    I get the following output:

    <pre>
    
    current_path = industry/government/test
    page_uri     = /industry/government/test
    
    ----
    
    Check current_path:
    
    FALSE
    
    ----
    
    Check page_uri:
    
    TRUE
    
    </pre><p>
    </pre>

    What am I missing??

    Furthermore, if I add a 3rd conditional i get an error message—> (Parse error: syntax error, unexpected ‘}’ ):

    {exp:channel:entries channel="industries" require_entry="true" limit="1"}
    <pre>
    
    current_path = {current_path}
    page_uri     = {page_uri}
    
    ----
    
    Check current_path:
    
    {if "{current_path}" == "industry/government/test"}
    TRUE
    {if:else}
    FALSE
    {/if}
    
    ----
    
    Check page_uri:
    
    {if "{page_uri}" == "/industry/government/test"}
    TRUE
    {if:else}
    FALSE
    {/if}
    
    ----
    
    Compare page_uri and current_path:
    
    {if "{page_uri}" == "/{current_path}"}
    TRUE
    {if:else}
    FALSE
    {/if}
    
    </pre>
    <p>{/exp:channel:entries}
    </pre>

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

ExpressionEngine News!

#eecms, #events, #releases