We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Conditionals not working

How Do I?

Christian Sweatt's avatar
Christian Sweatt
281 posts
about 11 years ago
Christian Sweatt's avatar Christian Sweatt

Hi Everyone!

I have a page where I want to display either a featured image or an image gallery in the left corner of a text block, which wraps around the image. Pretty basic.

If I use just a single image for the story, I have a class that shows a border around the image. If I decide to use a gallery (via a grid field), the images rotate, and the user can click on them to view larger versions. Also pretty simple.

The complication is evaluating whether either of the two is empty, and if so, show the one that has content. Further, if neither the gallery or single image have any content, show nothing.

My code is below. You can also view an example of what the single image is supposed to look like HERE. On the second page, I have the gallery set up, but nothing appears on the page when I load it HERE.

All this leads me to believe that there’s something I’m not doing correctly with the IF statements.

Thank you all for any help you can give!!

{exp:channel:entries channel="about" limit="1" sort="asc"}
 <h  class="headline">{if title != ""}{title}{/if}</h3><span class="line"></span><div class="clearfix"></div>
 {if gallery_section:total_rows >= "1"}
   <div class="five alt columns alpha">
 <!-- FlexSlider  -->
   <section class="flexslider post-img">
    <div class="media">
     <ul class="slides mediaholder">
      {gallery_section}
      <li>
       <a href="http://{gallery_section:about_image}%22class=%22mfp-gallery" title="{gallery_section:about_image_caption}" class="mfp-gallery">_        {gallery_section:about_image}_        <div class="hovercover">_         <div class="hovericon"><i class="hoverzoom"></i></div>_        </div>_       </a>
      </li>
      {/gallery_section}
      
     </ul>
    </div>
   </section>
   </div>
  {if:elseif about_image_single}
   {about_image_single}
  {/if}
 {about_full_body_text}
   
 {if no_results} {redirect="404"} {/if}

{/exp:channel:entries}
       
Christian Sweatt's avatar
Christian Sweatt
281 posts
about 11 years ago
Christian Sweatt's avatar Christian Sweatt

I’m surprised by how dead this forum seems to be. I haven’t been back here in a while, and things have certainly changed quite a bit… :red:

At any rate, I figured out a solution to this, and wanted to post, in case others ran into the same issue.

It turns out, I had to code the opening conditional in the following format:

{if '{gallery_section:total_rows}' >= '1'}

Notice the single quotes and brackets.

I’m not sure if this is a bug, but everything seems to be working fine now.

       
Jeremy S.'s avatar
Jeremy S.
353 posts
about 11 years ago
Jeremy S.'s avatar Jeremy S.

Most of the active community moved over here a couple years ago: http://expressionengine.stackexchange.com/

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.