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.

Most popular entries with conditional...Please Help :)

December 14, 2010 12:24pm

Subscribe [2]
  • #1 / Dec 14, 2010 12:24pm

    blaiseymae

    108 posts

    I have a tabbed box - viewable here publicmediaexchange, bottom left - that I am using to display the most popular entries on our site.

    All entries are published to a channel named “treatment”.  Some entries are viewable by everyone, and some only to member stations (determined by if member_group conditional and custom status).

    Audio and Video are determined by a custom field in the “treatment” channel publish page.

    I am using an if conditional to show only video or only audio.

    Everything seems to be working, but I cannot get the Limit=“2” to work.

    Here is my code:

    <div class="boxtop">
    
    <h1>MOST POPULAR</h1>
    
    </div> <!-- /boxtop -->
    
    <div class="spacer1"></div>
    
    <div class="tabbed-box">
    
    <ul class="tabs">
    
    <li><a href="#">VIDEO</a></li>
    
    <li><a href="#">AUDIO</a></li>
    
    </ul>
    
    
    
    <!-- Begin 1st tab content --><div class="tabbed-content">
    
    <div class="spacer10"></div>
    
    <div class="popular">
    
    <!-- Begin station view of all entries, no filtering -->
    {if member_group == "8" OR member_group == "9" OR member_group == "1"}
    
    {exp:channel:entries channel="treatment" orderby="view_count_one" sort="desc" disable="pagination|member_data|trackbacks" limit="2" dynamic="off"}
    
    {if media_type == "Video"}
    
    <div class="pop_box">
    
    {exp:imgsizer:size src="{treatment_img}" width="204"}
    
    <h2><a href="http://www.publicmediaexchange.org/index.php/treatment/{url_title}">{title}</a></h2>
    
    <h3>{identifierSource}</h3>
    <h4>Entry Date: {if treatment_date == ""}{entry_date format="%F %d, %Y"}{if:else}{treatment_date format="%F %d, %Y"}{/if}
    
    Media Type:  {titleType}
    
    Total Time:  {formatDuration}</h4>
    
    <p>{exp:word_limit total="20"}{description}{/exp:word_limit}</p>
    
    <p><a href="http://www.publicmediaexchange.org/index.php/treatment/{url_title}" class="more">Clip and Full Record</a></p>
    
    <p><div class="spacer2"></div></p>
    
    <p></div> <!-- /pop_box --></p>
    
    <p><hr ></p>
    
    <p>{/if}</p>
    
    <p>{/exp:channel:entries}</p>
    
    <p>{if:else}<!-- END STATION VIEW OF ALL ENTRIES, NO FILTERING | BEGIN PUBLIC VIEW --></p>
    
    <p>{exp:channel:entries channel="treatment" orderby="view_count_one" sort="desc" status="Public" disable="pagination|member_data|trackbacks" limit="2" dynamic="off"}</p>
    
    <p>{if media_type == "Video"}</p>
    
    <p><div class="pop_box"></p>
    
    <p>{exp:imgsizer:size src="{treatment_img}" width="204"}</p>
    
    <h2><a href="http://www.publicmediaexchange.org/index.php/treatment/{url_title}">{title}</a></h2>
    
    <h3>{identifierSource}</h3>
    <h4>Entry Date: {if treatment_date == ""}{entry_date format="%F %d, %Y"}{if:else}{treatment_date format="%F %d, %Y"}{/if}
    
    Total Time:  {formatDuration}</h4>
    
    <p>{exp:word_limit total="20"}{description}{/exp:word_limit}</p>
    
    <p><a href="http://www.publicmediaexchange.org/index.php/treatment/{url_title}" class="more">Clip and Full Record</a></p>
    
    <p><div class="spacer2"></div></p>
    
    <p></div> <!-- /pop_box --></p>
    
    <p><hr ></p>
    
    <p>{/if}</p>
    
    <p>{/exp:channel:entries}</p>
    
    <p>{/if}<br />
    <!-- END PUBLIC VIEW WITH FILTERING --></p>
    
    <p><a href="http://www.publicmediaexchange.org/index.php/treatment/{url_title}" class="more">More Video</a></p>
    
    <p><div class="spacer1"></div></p>
    
    <p></div> <!-- /popular --> </p>
    
    <p></div> <!-- /End 1st tab content --></p>
    
    <p> </p>
    
    <p><br />
    <!-- Begin 2nd tab content --><div class="tabbed-content"></p>
    
    <p><div class="spacer10"></div></p>
    
    <p><div class="popular"></p>
    
    <p><!-- Begin station view of all entries, no filtering --><br />
    {if member_group == "8" OR member_group == "9" OR member_group == "1"}</p>
    
    <p>{exp:channel:entries channel="treatment" orderby="view_count_one" sort="desc" disable="pagination|member_data|trackbacks" limit="2" dynamic="off"}</p>
    
    <p>{if media_type == "Audio"}</p>
    
    <p><div class="pop_box"></p>
    
    <p>{exp:imgsizer:size src="{treatment_img}" width="204"}</p>
    
    <h2><a href="http://www.publicmediaexchange.org/index.php/treatment/{url_title}">{title}</a></h2>
    
    <h3>{identifierSource}</h3>
    
    <h4>Entry Date: {if treatment_date == ""}{entry_date format="%F %d, %Y"}{if:else}{treatment_date format="%F %d, %Y"}{/if}
    
    Media Type:  {titleType}
    
    Total Time:  {formatDuration}</h4>
    
    <p>{exp:word_limit total="20"}{description}{/exp:word_limit}</p>
    
    <p><a href="http://www.publicmediaexchange.org/index.php/treatment/{url_title}" class="more">Clip and Full Record</a></p>
    
    <p><div class="spacer2"></div></p>
    
    <p></div> <!-- /pop_box --></p>
    
    <p><hr ></p>
    
    <p>{/if}</p>
    
    <p>{/exp:channel:entries}</p>
    
    <p>{if:else}<!-- END STATION VIEW OF ALL ENTRIES, NO FILTERING | BEGIN PUBLIC VIEW --></p>
    
    <p>{exp:channel:entries channel="treatment" orderby="view_count_one" status="Public" sort="desc" disable="pagination|member_data|trackbacks" limit="2" dynamic="off"}</p>
    
    <p>{if media_type == "Audio"}</p>
    
    <p><div class="pop_box"></p>
    
    <p>{exp:imgsizer:size src="{treatment_img}" width="204"}</p>
    
    <h2><a href="http://www.publicmediaexchange.org/index.php/treatment/{url_title}">{title}</a></h2>
    
    <h3>{identifierSource}</h3>
    
    <h4>Entry Date: {if treatment_date == ""}{entry_date format="%F %d, %Y"}{if:else}{treatment_date format="%F %d, %Y"}{/if}
    
    Total Time:  {formatDuration}</h4>
    
    <p>{exp:word_limit total="20"}{description}{/exp:word_limit}</p>
    
    <p><a href="http://www.publicmediaexchange.org/index.php/treatment/{url_title}" class="more">Clip and Full Record</a></p>
    
    <p><div class="spacer2"></div></p>
    
    <p></div> <!-- /pop_box --></p>
    
    <p><hr ></p>
    
    <p>{/if}</p>
    
    <p>{/exp:channel:entries}</p>
    
    <p>{/if}<br />
    <!-- END PUBLIC VIEW WITH FILTERING --></p>
    
    <p><a href="http://www.publicmediaexchange.org/index.php/treatment/{url_title}" class="more">More Audio</a></p>
    
    <p><div class="spacer1"></div></p>
    
    <p></div> <!-- /popular --></p>
    
    <p></div> <!-- /End 2nd tab content --><br />
        <br />
    </div> <!-- /End Tabbed Box -->

    Thanks, in advance 😊

  • #2 / Dec 14, 2010 12:27pm

    blaiseymae

    108 posts

    Also!  I am using custom status to filter entries based on whether they are approved for the public or not.

  • #3 / Dec 14, 2010 6:17pm

    Lisa Wess

    20502 posts

    Hi, blaiseymae - let me step back and explain what is happening here.

    Parameters (limit=, etc) limit the number of entries initially pulled in.

    Variables ({if….}, conditionals, etc) limit the display of the information pulled in.

    So say that you pull in 20 entries using parameters.  Then conditionals hide 19 of those entries.  You’ll get only 1 returned since they’re hidden after the fact.

    The solution here is to use the search parameter so you’re pulling in the content you actually want to work with, rather than using conditionals to hide content after the fact.

    Does that help?

  • #4 / Dec 15, 2010 11:05am

    blaiseymae

    108 posts

    FANTASTIC!!!

    That is awesome.  I love expressionengine!!!

    <3

  • #5 / Dec 15, 2010 5:17pm

    Ingmar

    29245 posts

    Glad to see Lisa was able to help. Please post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases