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.

pagination and categories

January 18, 2011 7:34am

Subscribe [3]
  • #1 / Jan 18, 2011 7:34am

    I’m working on a pagination and I want it to show up only when needed.
    ( so only when the # entries exceeds the limit I specified )

    for this I’m using:

    {paginate}
        {if {total_pages} > 1}
            <div id="pagination">
                {if previous_page}
                    <a href="http://{auto_path}">Previous Page</a>
                {/if}    
                   |   
                {if next_page}
                     <a href="http://{auto_path}">Next Page</a>
                {/if}    
             </div>    
        {/if}    
    {/paginate}

    this works, but not on the category pages. ( where I only show the entries posted in a specific category )
    I think this is because the {total_pages} tag counts the pages for ALL the entries, not only those within a certain category when specified ( which would make more sense in my opinion )


    any ideas ?

  • #2 / Jan 18, 2011 11:35pm

    John Henry Donovan

    12339 posts

    Hi Jan,

    What version and build of EE are you using?

    I don’t believe in the most recent version you need to use the total_pages conditional

    Can you give an example of your category page URL and what parameters you have for your channel entries tag please?

  • #3 / Jan 19, 2011 4:07am

    Hi Jan,

    What version and build of EE are you using?

    I don’t believe in the most recent version you need to use the total_pages conditional

    The current version of ExpressionEngine is v 2.1.0 Build 20101220

    Can you give an example of your category page URL and what parameters you have for your channel entries tag please?

    the overview page where the pagination works has this URL:

    _index.php/work/

    the category page is:

    _index.php/work/category/logo

    my channel entries tag looks like this:

    {exp:channel:entries channel="work" paginate="top" limit="24"}
  • #4 / Jan 19, 2011 4:14am

    Fixed it using this code:

    in mod.channel.php around line 2885:

    if ($this->p_page != 0 && $this->p_limit != 0)
    {
        $this->current_page = floor(($this->p_page / $this->p_limit) + 1);
    $this->total_pages = intval(floor($this->total_rows / $this->p_limit));                    
    }
    
    changes to
    
    $this->current_page = floor(($this->p_page / $this->p_limit) + 1);
    $this->total_pages = intval(floor($this->total_rows / $this->p_limit));

    source: https://support.ellislab.com/bugs/detail/13106/

  • #5 / Jan 19, 2011 5:10pm

    Ingmar

    29245 posts

    Thanks for letting us know, and glad you found a solution that works for you. Please post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases