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.

Help with Conditional Logic

May 11, 2011 12:56pm

Subscribe [4]
  • #1 / May 11, 2011 12:56pm

    NNWebmaster

    43 posts

    I’m trying to get the following code to work but to no avail:

    {if article_photo}
             {exp:imgsizer:size src="{article_photo}" width="450" height="300" alt="{title}" base_path="******" class="load" base_cache="******"}{/exp:imgsizer:size}
             <cite>{article_photo_caption} {if article_photo_credits}({article_photo_credits}){/if}</cite>
          {if:elseif article_gallery}
              <div id="slider">
              {article_gallery}
                {exp:imgsizer:size src="{cell_1}" width="450" height="300" alt="{cell_2}" base_path="*******" base_cache="*******"}{/exp:imgsizer:size}      
              {/article_gallery}
               </div>
         {if:elseif article_gallery && article_photo}
               <div id="slider">
              {article_gallery}
                {exp:imgsizer:size src="{cell_1}" width="450" height="300" alt="{cell_2}" base_path="*******" base_cache="*******"}{/exp:imgsizer:size}      
              {/article_gallery}
               </div>
         {if:else}        
          {/if}

    Everything works accept the {if:elseif article_gallery && article_photo} part. I’m thinking something might be wrong with my logic but I’m not seeing it. Need a fresh pair of eyes.

    Thanks!

  • #2 / May 11, 2011 2:35pm

    Natetronn

    161 posts

    I’m not following your logic to be honest or at least not quite sure what it is you are hoping to do though, would this work:

    {if article_photo}
        {exp:imgsizer:size src="{article_photo}" width="450" height="300" alt="{title}" base_path="******" class="load" base_cache="******"}{/exp:imgsizer:size}
        <cite>{article_photo_caption} {if article_photo_credits}({article_photo_credits}){/if}</cite>
    {if:else} 
        <div id="slider">
            {article_gallery}
                {exp:imgsizer:size src="{cell_1}" width="450" height="300" alt="{cell_2}" base_path="*******" base_cache="*******"}{/exp:imgsizer:size}      
            {/article_gallery}
        </div>            
    {/if}
  • #3 / May 11, 2011 3:45pm

    NNWebmaster

    43 posts

    That unfortunately doesn’t work. article_photo (nGEN) and article_gallery (Matrix) are two custom fields. I’m trying to get the condition where when both are true that the gallery of photos shows instead of just the photo.

    So when article_photo is true I see just the one photo, when article_gallery is true I see the photo gallery, but when I try the condition where both are true together, I see the just the one photo.

  • #4 / May 12, 2011 4:12am

    John Henry Donovan

    12339 posts

    NNWebmaster,

    try this

    {if article_photo != "" AND article_gallery == ""}
             {exp:imgsizer:size src="{article_photo}" width="450" height="300" alt="{title}" base_path="******" class="load" base_cache="******"}{/exp:imgsizer:size}
             <cite>{article_photo_caption} {if article_photo_credits}({article_photo_credits}){/if}</cite>
     {/if}
    
    {if article_photo == "" AND article_gallery != ""}
              <div id="slider">
              {article_gallery}
                {exp:imgsizer:size src="{cell_1}" width="450" height="300" alt="{cell_2}" base_path="*******" base_cache="*******"}{/exp:imgsizer:size}      
              {/article_gallery}
               </div>
    {/if}
    {if article_photo != "" AND article_gallery != ""}
               <div id="slider">
              {article_gallery}
                {exp:imgsizer:size src="{cell_1}" width="450" height="300" alt="{cell_2}" base_path="*******" base_cache="*******"}{/exp:imgsizer:size}      
              {/article_gallery}
               </div>      
       {/if}
  • #5 / May 13, 2011 4:04pm

    NNWebmaster

    43 posts

    Thanks John. That works!

  • #6 / May 13, 2011 4:22pm

    Brandon Jones

    5500 posts

    Nice one John Henry! Glad that works, NNWebmaster.

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

ExpressionEngine News!

#eecms, #events, #releases