Not signed in (Sign In)

Vanilla 1.1.10 is a product of Lussumo. More Information: Documentation, Community Support.

  1.  
    Assume im having 50 images and im displaying 5 images per page then it should display in 10 pages

    as per the present coding pagination is shown as 1 2 3 4 5 6 7 8 9 10

    the same case when there are 200 pages of images

    pagination is shown from 1 2 3 4 ........199 200 that will spoil the look of template as well

    just try 50 images displaying 1 per page you can see how the pagination is when there are many pages


    so i think there should be an advanced pagination such that it displays only 5 or certain number of pages number at one time....(ie like how google displays 10 pages at a time )

    this is very much needed specially when you have more number of images...
    •  
      CommentAuthorsidtheduck
    • CommentTimeMay 29th 2009
     
    Yep, there's already a Trac ticket created for this enhancement -> Ticket #214
  2.  
    with some knowledge of php i tried to write the logic.... it did work..... correct if something was wrong or can be simplified....

    i edited this function in plog-functions.php

    function generate_pagination($level, $id, $current_page, $items_total, $items_on_page, $args = array()) {
    $output = '';

    if (!isset($GLOBALS['total_pictures'])) $GLOBALS['total_pictures'] = 0;

    if (($items_total == 0) && ($GLOBALS['total_pictures'] > 0)) {
    $items_total = $GLOBALS['total_pictures'];
    }

    $num_pages = ceil($items_total / $items_on_page);

    if ($num_pages > 1) {
    if ($current_page > 1) {
    if ($current_page != 2) {
    $args[1] = 'page';
    $args['plog_page'] = $current_page - 1;
    }
    $output .= '<a title="'.plog_tr('Previous').'" accesskey="," class="pagPrev" href="'.generate_url($level, $id, $args).'"><span>&laquo;</span></a>';
    }

    if ($num_pages > 6) {
    if ($current_page - 3 > 0){
    if ($current_page + 3 < $num_pages){
    for ($i =$current_page - 3; $i <= $current_page + 3; $i++)
    {
    if ($i == $current_page) {
    $output .= '<span class="page-link-current">'.$i.'</span>';
    } else {
    if ($i != 1) {
    $args[1] = 'page';
    $args['plog_page'] = $i;
    } else {
    unset($args[1]);
    unset($args['plog_page']);
    }
    $output .= '<a href="'.generate_url($level, $id, $args).'" class="page-link">'.$i.'</a>';
    }
    }
    }

    else{
    for ($i =$current_page - 3; $i <= $num_pages; $i++)
    {
    if ($i == $current_page) {
    $output .= '<span class="page-link-current">'.$i.'</span>';
    } else {
    if ($i != 1) {
    $args[1] = 'page';
    $args['plog_page'] = $i;
    } else {
    unset($args[1]);
    unset($args['plog_page']);
    }
    $output .= '<a href="'.generate_url($level, $id, $args).'" class="page-link">'.$i.'</a>';
    }
    }
    }



    }//if end
    else{

    if($current_page + 3 < $num_pages){
    for ($i = 1; $i <= $current_page + 3; $i++)
    {
    if ($i == $current_page) {
    $output .= '<span class="page-link-current">'.$i.'</span>';
    } else {
    if ($i != 1) {
    $args[1] = 'page';
    $args['plog_page'] = $i;
    } else {
    unset($args[1]);
    unset($args['plog_page']);
    }
    $output .= '<a href="'.generate_url($level, $id, $args).'" class="page-link">'.$i.'</a>';
    }
    }

    }//if end

    else{
    for ($i = 1; $i <= $num_pages; $i++)
    {
    if ($i == $current_page) {
    $output .= '<span class="page-link-current">'.$i.'</span>';
    } else {
    if ($i != 1) {
    $args[1] = 'page';
    $args['plog_page'] = $i;
    } else {
    unset($args[1]);
    unset($args['plog_page']);
    }
    $output .= '<a href="'.generate_url($level, $id, $args).'" class="page-link">'.$i.'</a>';
    }
    }
    }

    }//else end


    }// num-pages end

    else{
    for ($i = 1; $i <= $num_pages; $i++)
    {
    if ($i == $current_page) {
    $output .= '<span class="page-link-current">'.$i.'</span>';
    } else {
    if ($i != 1) {
    $args[1] = 'page';
    $args['plog_page'] = $i;
    } else {
    unset($args[1]);
    unset($args['plog_page']);
    }
    $output .= '<a href="'.generate_url($level, $id, $args).'" class="page-link">'.$i.'</a>';
    }
    }
    } // num-pages < 6


    if ($current_page != $num_pages) {
    $args[1] = 'page';
    $args['plog_page'] = $current_page + 1;
    $output .= '<a title="'.plog_tr('Next').'" accesskey="." class="pagNext" href="'.generate_url($level, $id, $args).'"><span>&raquo;</span></a>';
    }
    }

    return $output;
    }
    Thankful People: edwink, andrewjs18
  3.  
    harsha2kiran,

    I did you mod, saved it, overwrote old file and refreshed the page..is there something in the database I need to do to get this new pagination to work because it didn't work on my end with just overwriting the old file.
  4.  
    andrewjs18

    hm.. all i did is jus changed the way it displays those page numbers...so nothing to be changed in database....

    i jus replaced function generate_pagination in plog-functions.php.....

    i tried this on trunk 596 version....may be you are using a different version.. folder structure, few functions and the way parameters are passed through those functions were changed from beta3.0 version to trunk596 version...
    • CommentAuthorandrewjs18
    • CommentTimeJun 7th 2009 edited
     
    Wait...

    It did work..I had some other issues I worked out.

    If I'm correct, it shows 4 pages at a time and when you click on the 4th page, it loads more page numbers?

    If so- it's perfect!

    Thanks!
    •  
      CommentAuthorsidtheduck
    • CommentTimeJun 10th 2009
     
    Thanks for posting your code, harsha2kiran.

    I'll definitely get it included into the SVN code at some point here soon and try to integrate an Option in the Admin -> Options tab or modify it as a theme function for people to specify how many numbers are shown and what to show between numbers, etc. (just to give the user some additional options in how to customize the display).

    Thanks again!
    •  
      CommentAuthorsidtheduck
    • CommentTimeOct 26th 2009
     
    I have included a modified version of harsha2ikran's code into the core of Plogger as of revision 603. You can read this post describing how to use the new pagination function in your theme file.
    • CommentAuthorAndromeda
    • CommentTimeFeb 4th 2010 edited
     
    I tried your code and I recived this message:

    Warning: Missing argument 5 for generate_pagination() in plog-functions.php

    Warning: Division by zero in plog-functions.php


    (I don't know exactly my Plogger B3 Revision)
    •  
      CommentAuthorkimparsell
    • CommentTimeFeb 4th 2010
     
    @Andromeda: The cost posted here works with the latest version of Plogger (1.0 RC1). In order to use this, you should upgrade your gallery to the latest version.