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.

Popular Posts by Month - limit # of posts displayed?

October 23, 2011 6:28pm

Subscribe [2]
  • #1 / Oct 23, 2011 6:28pm

    lalcala1

    2 posts

    Hello,

    I’ve managed to show a list of popular posts for the past month; however, I’d like to limit the number of posts that are displayed. Since I’m using the display_by=“month” variable, the limit=“1” pertains to the month variable and I’m unsure how to limit the number of posts displayed in this instance.

    Here is my code:

    <div class="grid_6 omega">
    <h3>Most Popular This Month</h3>
    <p><ul><br />
    {exp:weblog:entries weblog="blog" orderby="view_count_one" dynamic="no" status="open||featured" display_by="month" limit="1"}<br />
    <li><a href="http://{title_permalink=">{title}</a></li><br />
    {/exp:weblog:entries} <br />
    </ul><br />
    </div>

    Thank you for any advice!

  • #2 / Oct 24, 2011 7:21am

    ahmad saad

    364 posts

    I don’t think there is a parameter can help u

    put u can work around use count like this:

    <div class="grid_6 omega">
    <h3>Most Popular This Month</h3>
    <p><ul><br />
    {exp:weblog:entries weblog="blog" orderby="view_count_one" dynamic="no" status="open||featured" display_by="month" limit="1"}<br />
    {if count < "5"}<br />
    <li><a href="http://{title_permalink=">{title}</a></li><br />
    {/if}<br />
    {/exp:weblog:entries} <br />
    </ul><br />
    </div>

  • #3 / Oct 24, 2011 11:22pm

    John St-Amand

    865 posts

    Instead of display by month, you could use the simple month= parameter and dynamically populate it to the current month by using the current_time global variable.  Then the limit parameter still remains available to you.  The downside would be that it would show only items from within the current month, rather than the last 30 days - but I think display by month has the same limitation.

    So I think you could do this:

    <div class="grid_6 omega">
    
    {exp:weblog:entries weblog="blog" orderby="view_count_one" dynamic="no" status="open||featured" month="{current_time format="%m"}" limit="6"}
    {if count == "1"}<h3>Most Popular This Month</h3>
    <p><ul>{/if}</p>
    
    <p><li><a href="http://{title_permalink=">{title}</a></li><br />
    {if count == total_results}</ul>{/if}<br />
    {/exp:weblog:entries} </p>
    
    <p></div>

    I also simultaneously threw the heading and <ul></ul> tags inside the entries tags with conditionals around them so that if there were no results, nothing would display, not even the heading and ul tags.

    Hope that helps/works.  Please let me know.

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

ExpressionEngine News!

#eecms, #events, #releases