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 Variables

November 14, 2012 2:36pm

Subscribe [2]
  • #1 / Nov 14, 2012 2:36pm

    design826

    36 posts

    1.) How do I setup a conditional variable so when there are no entries it posts the following text in the title position “There are no events at this time.”?

    For example:

    {exp:channel:entries channel="blog" orderby='expiration_date' sort='asc' limit="3" category="2"}
     <li>
     <div class="txt">
     <h3><a href="http://{exp:brilliant_retail:path">{title}</a></h3>
    <p> </div> </li> <br />
    {/exp:channel:entries}


    2.) How do I setup a conditional variable so when there is an empty field it doesn’t show? In this case, it’s an image. If I don’t have an image it shows a white box. I would like it to show nothing.

    For example:

    {exp:channel:entries channel="blog" limit="1"}
    <div id="subject">
         
     {blog_photo_detail}
    
    
      {blog_content}
            </div>
    {/exp:channel:entries}

    Thanks.

    mod edit: wrapped examples in code tags for readability.

  • #2 / Nov 15, 2012 2:39am

    DigitalDoctors

    76 posts

    1.

    {exp:channel:entries channel=“blog” orderby=‘expiration_date’ sort=‘asc’ limit=“3” category=“2”}
        {if no_results}
            There are no events at this time
        {/if}
    {/exp:channel:entries}

    See Channel Entries documentation - http://ellislab.com/expressionengine/user-guide/modules/channel/channel_entries.html#if-no-results

    2.

    Simply wrap the variable in an if statement:

    {if blog_photo_detail}
        {blog_photo_detail}
    {/if}
  • #3 / Nov 15, 2012 4:41pm

    design826

    36 posts

    Great, that worked. Thanks for your help.

  • #4 / Nov 16, 2012 11:31am

    Dan Decker

    7338 posts

    Hi design826,

    I’m glad you got an answer from DigitalDoctors!

    If you need anything else, please let us know!

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases