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.

exp:channel:entries + multiple if statements

October 10, 2011 4:04pm

Subscribe [2]
  • #1 / Oct 10, 2011 4:04pm

    leviticus

    6 posts

    I am having trouble pulling entries in my sidebar on channel templates that have if:else statements dictating which content to display. The sidebar entries will display on main level/landing pages such as http://www.lcc-wf.com/about, but not on interior pages such as http://www.lcc-wf.com/about/documents.

    I am new with if:else statements in EE, so I’m hoping someone can help me get them sorted out to display the correct entries.

    Here’s the main code for the about/index template:

    {if segment_2==""} <!-- a landing page -->   
    <h2>About Us</h2>
    
    <p>{exp:channel:entries channel="about" disable="{disable_options}"}<br />
        {if entry_id=="99"}<br />
            {body}<br />
        {/if}<br />
    {/exp:channel:entries}</p>
    
    <h2>More about LCC</h2>
    <p>{exp:channel:category_archive channel="about" style="linear" show="52|53|54" show_group="not 9"}<br />
        {categories}<br />
        <br />
        </p><h3>{category_name}</h3><p> <br />
        <br />
        {exp:channel:entries channel="about" category="{category_id}" disable="{disable_options}"}<br />
            </p><h3><a href="/about/{url_title}">{title}</a></h3>
    <p>        <br />
            {if featured_image!=""}<br />
            <a href="/about/{url_title}">{featured_image}</a><br />
            {/if}<br />
            {excerpt}<br />
            <br />
            <a href="/about/{url_title}">More information…</a><br />
        {/exp:channel:entries}<br />
        <br />
        {/categories}<br />
    {/exp:channel:category_archive}</p>
    
    <p>{if:elseif segment_2!=""} <!--  a detail page --><br />
        {embed="includes/entry_single"}<br />
        <br />
    {if:else}<br />
    {/if}</p>
    
    <p><aside id="secondary" class="grid_4"><br />
        {embed="includes/search"}<br />
        {embed="includes/sidebar"}<br />
    </aside>

    Here’s the main code for the includes/entry_single template:

    {exp:channel:entries channel="{embed:channel_option}" limit="1" disable="{disable_options}"}
        <h2>{title}</h2>
    <p>    {body}<br />
    {/exp:channel:entries}

    Here’s the main code for the includes/sidebar template:

    <ul id="tab-heading">
        <li class="selected"><a href="#worship">Worship</a></li>
        <li><a href="#education">Education</a></li>
    </ul>
    
    <section id="tabs">
        <ul id="worship">
            <li>
            {exp:channel:entries channel="sidebar" entry_id="33" disable="{disable_options}"}
            {sidebar_body}
            {/exp:channel:entries}
            </li>
        </ul>
        <ul id="education">
            <li>
            {exp:channel:entries channel="sidebar" entry_id="34" disable="{disable_options}"}
            {sidebar_body}
            {/exp:channel:entries}
            </li>
        </ul>
    </section>
    
    {exp:channel:entries channel="sidebar" category="55" disable="{disable_options}"}
        <section>
            <h3>{if link_to_page!=""}<a href="http://{link_to_page}">{title}</a>{if:else}{title}{/if}</h3>
    <p>        {sidebar_body}<br />
        </section><br />
    {/exp:channel:entries}

    EE v2.2.2

  • #2 / Oct 11, 2011 3:28am

    John Henry Donovan

    12339 posts

    Hi leviticus,

    Try adding the dynamic=“no” parameter to your Channel Entries tags.

  • #3 / Oct 11, 2011 1:58pm

    leviticus

    6 posts

    That did the trick.  Thanks so much! 😊

  • #4 / Oct 11, 2011 11:45pm

    Dan Decker

    7338 posts

    leviticus,

    That’s excellent! Thanks for letting us know you all squared away. If you need assistance in the future, let us know in a new thread.

    Cheers!

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

ExpressionEngine News!

#eecms, #events, #releases