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.

Set number of pagelinks in EE pagination.

March 29, 2012 10:47pm

Subscribe [2]
  • #1 / Mar 29, 2012 10:47pm

    Sunnyland

    66 posts

    I need to set the number of pagelinks displayed between previous and next buttons in EE Pagination.

    I’m currently ristricting my projects channel to display 1 entry at a time, and paging them via small dots to the RHS of the page.
    (Using CSS to convert pagelinks, 1, 2, 3 etc into dots.)

    I want to increase the number of dots (pagelinks) being displayed between the left and right arrows (next and previous buttons)
    - or just display them all.

    Link to site below (as of March 30 2012):
    http://www.vsdesign.com.au/index.php/site/our_work/projects/branding/P1

    Channel tag:

    {exp:channel:entries channel="projects" disable="trackbacks" paginate="bottom" limit="1" orderby="date" sort="desc" paginate="top"}

    Pagination Code:

    {paginate}
         {pagination_links}       
          <ul class="dots">
    
           {previous_page}
            <li><a href="http://{pagination_url}" class="page-previous">Previous Page</a></li>
           {/previous_page}
    
           {page}
            <li><a href="http://{pagination_url}" class="page-{pagination_page_number} {if current_page}current{/if}">{pagination_page_number}</a></li>
           {/page}
    
           {next_page}
            <li><a href="http://{pagination_url}" class="page-next">Next Page</a></li>
           {/next_page}
    
          </ul>
         {/pagination_links}
        {/paginate}

    v2.3.1 - Build: date 20111017

    If anyone could help me out, that would be sweet.
    Ask me if you need any other info.

     

  • #2 / Apr 02, 2012 3:05am

    Sunnyland

    66 posts

    I’m also wondering if I can edit the way urls are generated for the page links, i.e to utilize entry titles or number from the last page, rather than the first (or second).

    I need to link statically to projects from the homepage, and I’m sorting projects by date desc (newest first) - but the page links are numbered ascending, meaning that when I add a new project, it changes all the numbers and breaks the links.

    If anyone has any idea how to overcome any of these issues, I would really appreciate some help.

  • #3 / Apr 02, 2012 7:23am

    ahmad saad

    364 posts

    go to /system/libraries/Pagination.php

    and changr the var

    var $num_links   =  2; // Number of "digit" links to show before/after the currently viewed page

    the defualt val is 2 befor and 2 after current page that give you 5 pages

    if you change it to 3 you will get 7 pages.

    I hope this will be helpfull

  • #4 / Apr 02, 2012 7:53pm

    Sunnyland

    66 posts

    Thankyou so much, that worked perfectly!


    For anybody else’s reference: I found this file in: public_html(site_root)/system/codeigniter/system/libraries/Pagination.php
     

  • #5 / Apr 02, 2012 8:42pm

    Sunnyland

    66 posts

    Do you have any idea about how to change the order of numbering for the auto generated pagelinks as well?

    I couldn’t tell if some of the vars might affect this, or whether it would be coded in.
    But since I linking to projects and ordering entries by date descending, my static links to these projects are breaking when a new entry is added.

    If I could start numbering at 1 from the last (oldest) entry, instead of 0 from the first (newest)  entry, that should fix the problem.

    I also wondered if the links could be generated from a title or entry id instead of a dynamic count, i.e. P1, P2, P3, etc.

    If anyone knows what I’m talking about, or has seen this sort of thing done before, any help would be appreciated.

  • #6 / Apr 03, 2012 6:48am

    ahmad saad

    364 posts

    I visite your site and I see that the functionality you want can be done without pagination.

    how I understand you want to generate a side dots to navigate the projects and you view one project by page, so simply use {exp:channel:entries like this:

    <ul class="dots">
    
    {exp:channel:prev_entry channel="projects"}
        <li><a href="http://{permalink=%27site/our_work/projects/branding/%27}" class="page-previous">Previous Page</a></li>    
    {/exp:channel:prev_entry}
    
    {exp:channel:entries channel="projects" disable="trackbacks" orderby="date" sort="desc" dynamic="no"}       
            <li><a href="http://{permalink=%27site/our_work/projects/branding/%27}" class="page-{count} {if ">{count}</a></li>
    {/exp:channel:entries}
    
    {exp:channel:next_entry channel="projects"}
            <li><a href="http://{permalink=%27site/our_work/projects/branding/%27}" class="page-next">Next Page</a></li>
    {/exp:channel:next_entry}   
    
          </ul>

    I don’t test it , but I think this will be work for you.

    tell me if it’s working

  • #7 / Apr 03, 2012 7:43pm

    Sunnyland

    66 posts

    This looks like a great idea.

    Though not working at the moment.

    It gives me a white page with the following error:

    Parse error: syntax error, unexpected T_STRING in /home/vsdesign/public_html/system/expressionengine/libraries/Functions.php(656) : eval()'d code on line 62

    I’m not sure about this part:

    class="page-{count} {if "

    Also it will be necessary to differentiate between the page categories (i.e. branding, packaging, web etc), which are selected from the url segment (based on which link was clicked) as each category uses the same template and channel.

    Perhaps

    {category_name}

    will suffice…

    Thanks a lot for your innovative thinking and helpful ideas.

  • #8 / Apr 05, 2012 1:35am

    ahmad saad

    364 posts

    this part like this:

    class="page-{count} {if "{last_segment}"=="{url_title}"}current{/if}"
  • #9 / Apr 05, 2012 2:12am

    Sunnyland

    66 posts

    OK that didn’t break :D
    But it’s only yielded 1 pagelink.

    OOPS and I noticed that the additional entries are placing down the side…

  • #10 / Apr 05, 2012 2:27am

    Sunnyland

    66 posts

    OK I just figured out that I had to place the ul code outside of the {exp:channel:entries} tags, which fixed it to some degree.

    It looks like it’s calling in the right number of pagelinks now, though while the generated URL is different, each one is still displaying the same entry…

    I’ll change it back for now until we can get the new method working.

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

ExpressionEngine News!

#eecms, #events, #releases