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.

Show Entries based on Condition

August 11, 2009 1:52am

Subscribe [2]
  • #1 / Aug 11, 2009 1:52am

    Nick Gascoigne

    14 posts

    I’m trying to figure out how to change the entry_id based on a conditional. The below only shows the first condition “33” in all instances. What am I doing wrong?

    {if "{segment_1}"=="es"}
                    {assign_variable:post_lang="33"}
                {if:elseif "{segment_1}"=="pt"}
                    {assign_variable:post_lang="34"}
                {if:else}
                    {assign_variable:post_lang="32"}
                {/if}
                {exp:weblog:entries weblog="home" entry_id="{post_lang}" limit="1" dynamic="off"}
                    <h3>{title} {post_lang}</h3>
    <p>                {page_content}<br />
                {/exp:weblog:entries}

  • #2 / Aug 11, 2009 2:32am

    John Henry Donovan

    12339 posts

    Nick,

    What you have will not work as there is a Parse Order to a template and assign_variable is completed before any conditionals.

    You can use conditions this way though

    {if segment_1=="es"}
                {exp:weblog:entries weblog="home" entry_id="33" limit="1" dynamic="off"}
                    <h3>{title} {post_lang}</h3>
    <p>                {page_content}<br />
                {/exp:weblog:entries} <br />
     {/if}</p>
    
    <p>{if segment_1=="pt"}<br />
                {exp:weblog:entries weblog="home" entry_id="34" limit="1" dynamic="off"}<br />
                    </p><h3>{title} {post_lang}</h3>
    <p>                {page_content}<br />
                {/exp:weblog:entries} <br />
     {/if}

  • #3 / Aug 11, 2009 2:43am

    Nick Gascoigne

    14 posts

    Thanks John.

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

ExpressionEngine News!

#eecms, #events, #releases