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.

How do I make an if statement regarding category entries?

November 03, 2011 9:26pm

Subscribe [2]
  • #1 / Nov 03, 2011 9:26pm

    Ger

    5 posts

    I’m probably overlooking something extremely basic, as I just started learning EE.

    I’m trying to build a portfolio for a client inside of a jQuery slider. The slider populates with thumbnails of each entries submitted. Each slider page can hold 18 new entries from the portfolio channel. The portfolio channel is divided into 5 categories, logos, print, web, video, and other.

    I have also designed it so that you can view only entries from one category. By adding the value of the category to the URL I can make the slider only show specific entries as shown below.

    <div id="slideshow">
               <div id="slidesContainer">
       <!-- Slide 1 -->
       <div class="slide">
                 <div class="Row">
        {exp:channel:entries channel="portfolio" category="{last_segment}" limit="18"}
                     {portfolio_entry}
                          {/exp:channel:entries}
               </div>
       </div>
       <!-- End Slide 1 -->
       
       {if ?category entries? => 18}
       <!-- Slide 2 -->
       <div class="slide">
                 <div class="Row">
        {exp:channel:entries channel="portfolio" category="{last_segment}" limit="18" offset="18"}
                     {portfolio_entry}
                          {/exp:channel:entries}
               </div>
       </div>
       <!-- End Slide 2 -->
       {/if}
      </div>
    </div>

    My problem is, once I’m viewing a specific category how do I add a conditional statement instructing to only show slide to if their are more than 18 entries in the Logos category?

    Or do I need to scrap all this and start over with a new structure?

  • #2 / Nov 04, 2011 11:49am

    Darren Miller

    103 posts

    I think you can do it in one channel:entries tag

    I’ve not tested this but if I understand your template correctly it should do what you need.:

    <div id="slideshow">
     <div id="slidesContainer">
    
       {exp:channel:entries channel="portfolio" category="{last_segment}" limit="36"}
       {if count == 1 || count == 19}
        <div class="slide">
                 <div class="Row">
       {/if}
               {portfolio_entry}
    
       {if count == 18 || count == total_results}
       </div>
      </div>
       {/if}
    
       {/exp:channel:entries}
    
     </div>
    </div>
  • #3 / Nov 06, 2011 10:30am

    Ger

    5 posts

    YES! This is exactly what I needed. I see the “count” part is what I was looking for all along. I’ve already put this to use in some other parts of the site as well.

    Thank you so much!

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

ExpressionEngine News!

#eecms, #events, #releases