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 conditionals and embeded variables

September 11, 2011 10:52am

Subscribe [2]
  • #1 / Sep 11, 2011 10:52am

    Gajus

    5 posts

    This is the page template:

    {exp:channel:entries channel="pages" limit="1"}
    {embed="embeds/header" active_entry_id="{entry_id}"}
    <div id="static-page" class="body">
    <h1>{title}</h1>
    
    {body}
    </div>
    {embed="embeds/footer"}
    {/exp:channel:entries}

    The page template embeds the header template. The following is the header template responsible for generating navigation:

    <ul class="navigation">
        {exp:channel:entries channel="pages" show_pages="only" search:appear_on_navigation="yes"}
        <li {if entry_id == embed:active_entry_id}class="active"{/if} ><a href="http://{page_url}">{title} |{entry_id}#{embed:active_entry_id}|</a>
        </li>
        {/exp:channel:entries}
    </ul>

    Notice the “entry_id == embed:active_entry_id” & “|{entry_id}#{embed:active_entry_id}|” in the header template. The problem is, that “|{entry_id}#{embed:active_entry_id}|” prints “|7#7|”, however, the IF conditional returns false.

    What is it that I am doing wrong? and, is it generally the right way to get the present active entry ID inside the navigation?

  • #2 / Sep 12, 2011 1:13pm

    the3mus1can

    426 posts

    Try this:

    <ul class="navigation">
        {exp:channel:entries channel="pages" show_pages="only" search:appear_on_navigation="yes"}
        <li {if "{entry_id}" == "{embed:active_entry_id}"}class="active"{/if} ><a href="http://{page_url}">{title} |{entry_id}#{embed:active_entry_id}|</a>
        </li>
        {/exp:channel:entries}
    </ul>
  • #3 / Sep 12, 2011 1:16pm

    Gajus

    5 posts

    I did. Didn’t work. Though, worth noting as well is that,

    embed:active_entry_id == 7
    or
    embed:active_entry_id == "7"
    also return false. Once again, though.
    #{embed:active_entry_id}#

    prints #7#.

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

ExpressionEngine News!

#eecms, #events, #releases