0

I have this peice of code:

    <div id="slide-block1" class="flexslider">  
        <div class="slides">

          {exp:channel:entries
          channel="rotator-slides"
          disable="categories|category_fields|member_data|pagination"
          orderby="random"
          dynamic="no"
          category="262"
          }
              <div class="slide">
                <a href="{slide-link}">
                  {exp:imgsizer:size src="{slide-image}" width="960" height="430"}
                  <img src="{sized}" width="960" height="430" alt="" />
                  {/exp:imgsizer:size}
                </a>
              </div><!-- /.slide -->
          {/exp:channel:entries}

        </div><!-- /.slides -->
      </div><!-- /#slide-block1 -->

The problem is that I do not want the first two "div" tags (and therefore the last two closing tags) to appear if the channel with that category has at most 1 entry. How do I get the total number of entries before using the channel tag?

1 Answer 1

0

I think I fixed it. I feel stupid. All I needed is to make a condition inside the tag!

      {exp:channel:entries
      channel="rotator-slides"
      disable="categories|category_fields|member_data|pagination"
      orderby="random"
      dynamic="no"
      category="262"
      }
      {if total_results > "1" && count=="1"}
      <div id="slide-block1" class="flexslider">  
        <div class="slides">
          {/if}
          <div class="slide">
            <a href="{slide-link}">
              {exp:imgsizer:size src="{slide-image}" width="960" height="430"}
              <img src="{sized}" width="960" height="430" alt="" />
              {/exp:imgsizer:size}
            </a>
          </div><!-- /.slide -->
          {if total_results > "1" && count==total_resutls}
        </div><!-- /.slides -->
      </div><!-- /#slide-block1 -->
      {/if}
      {/exp:channel:entries}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.