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.

Channel Entries Listing: Show {paginate} even if there's only one page

April 04, 2012 9:31am

Subscribe [1]
  • #1 / Apr 04, 2012 9:31am

    PhireGuys

    525 posts

    EE 2.4:

    {exp:channel:entries channel="performances" 
            sort="asc" 
            limit="5" 
            paginate="both" 
            dynamic="no"
            category="4"
    }


    In my channel entries tag, I have paginate=“both”.  I’d like the code within my {paginate}{/paginate} tags to show up even if there is only one page available for styling purposes.  Everything works great when there are indeed multiple pages.  Is there some kind of parameter I’m missing?

    Pagination code is kind of long but doesn’t contain any conditionals.  The general gist is:

    {paginate}
    <unrelated html>
      {pagination_links}
        {previous_page}...{/previous_page}
        {page}...{/page}
        {next_page}...{/next_page}
      {/pagination_links}
    <unrelated html>
    {/paginate}
  • #2 / Apr 04, 2012 11:21am

    glenndavisgroup

    436 posts

    Hi PhireGuys,

    Try the following:

    {exp:channel:entries channel="performances" sort="asc" limit="5" paginate="both" dynamic="no" category="4"}  
    
    ...some EE and html code here
    
    {paginate}
    {if next_page || previous_page}
    <unrelated html>
      {pagination_links}
        {previous_page}...{/previous_page}
        {page}...{/page}
        {next_page}...{/next_page}
      {/pagination_links}
    <unrelated html>
    {if:else}
    
    ...put your custom no pagination html here
    
    {/if}
    {/paginate}
    
    {/exp:channel:entries}

    The if statement in the pagination tag checks to see if we can go next or previous which will be true if we have pagination and displays the pagination buttons as usual. But if we can’t go next or previous that means it’s a short list and displays your custom pagination in the else. Put your custom html in the else above and you should be able to display pagination even when you don’t have enough entries. I hope that helps.

    Mike

  • #3 / Apr 05, 2012 10:38am

    Dan Decker

    7338 posts

    Hi PhireGuys,

    Mike’s suggestion is spot on, thanks Mike!

    Let me know if you need alternatives!

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases