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.

entry pagination question - if last post conditional

June 08, 2008 3:58am

Subscribe [2]
  • #1 / Jun 08, 2008 3:58am

    Corey Lane

    34 posts

    I have entries from a weblog paginated, 5 per page. I have a divider image in my template that goes in between each blog entry. Link to page The problem is, the divider shows up on the last post of the page, creating an unnecessary divider. Is there anyway with an if conditional or some other method to NOT show the divider if the entry is the last entry on the page.

    {exp:weblog:entries weblog="staff" sort="asc" limit="5" paginate="bottom"}
      
      <div class="staff-member">
        <h3 class="clear"><a href="http://{path=about/staff/{url_title}}">{title}</a> - {position}</h3>
        {staff-photo} {staff-member-bio}
            
            <!-- blog entry divider -->
            <div class="hr"><hr ></div>
    
      <!-- close staff-member -->
      </div>
      
      {paginate} {pagination_links}{/paginate}
     {/exp:weblog:entries}
  • #2 / Jun 08, 2008 10:48am

    Robin Sowell

    13255 posts

    Try it with

    {if total_results Q= count}
            <!-- blog entry divider -->
            <div class="hr"><hr ></div>
    {/if}

    Think that should do the trick.

  • #3 / Jun 08, 2008 3:00pm

    Corey Lane

    34 posts

    Robin, I tried your code and received the following error on the page:

    Parse error: syntax error, unexpected T_STRING in /home/wbcweb/public_html/system/core/core.functions.php(637) : eval()'d code on line 26

    EE 1.6.3 / Build: 20080421

  • #4 / Jun 08, 2008 5:43pm

    Mark Bowen

    12637 posts

    I think maybe Robin slipped on the keyboard earlier maybe? 😉

    The code should be :

    {if total_results == count}
    <!-- blog entry divider -->
    <div class="hr"><hr ></div>
    {/if}

    Hopefully that should do it for you.

    Best wishes,

    Mark

  • #5 / Jun 08, 2008 6:01pm

    Corey Lane

    34 posts

    Hi Mark, thanks for your response. Close, but no cigar…

    That code puts the divider on the last post only. I want the divider on every post but the last. I threw in an if:else which solved that issue. Thanks to both of you for the help!

    The first if statement is empty, is that kosher? It seems to be working exactly the way I want it to.

    {if total_results == count}
      {if:else}
      <!-- blog entry divider --><div class="hr"><hr ></div>
    {/if}
  • #6 / Jun 08, 2008 6:24pm

    Mark Bowen

    12637 posts

    Oops sorry!

    Didn’t read the post correctly.

    Should be this code then :

    {if total_results != count}
    <!-- blog entry divider -->
    <div class="hr"><hr ></div>
    {/if}

    😊

    Best wishes,

    Mark

  • #7 / Jun 09, 2008 12:58am

    Corey Lane

    34 posts

    Thanks again Mark.

  • #8 / Jun 09, 2008 1:26am

    Corey Lane

    34 posts

    I always forget about global variables, they are helpful.

    {if total_results != count}
    <!-- blog entry divider -->
    {divider}
    {/if}
  • #9 / Jun 09, 2008 5:56am

    Mark Bowen

    12637 posts

    Yep you can do that too 😉

    Glad you are all set now.

    Best wishes,

    Mark

  • #10 / Jun 09, 2008 10:29am

    Robin Sowell

    13255 posts

    Heh- for some reason I had a Q instead of an equal sign in the example code.  😉  Yea- that wouldn’t work.

    Glad Mark got you squared- I’m closing this on out.

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

ExpressionEngine News!

#eecms, #events, #releases