Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Smarty Pagination

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Tonata
Smarty Rookie


Joined: 28 Jun 2010
Posts: 5

PostPosted: Sun Sep 30, 2012 10:28 pm    Post subject: Smarty Pagination Reply with quote

Hi guys,

I am trying to implement the PHP SmartyPaginate by Monte Ohrt. I have about 1000 records that I need to display.. I don't know how to limit the number of ranges displayed ({paginate_middle}). I am displaying 10 items per page, this means I have 100 pages and all these ranges are being displayed at ones, thus making the page untidy.. I just want to display ranges of up to 40 items and increase as needed. an example of what I want is like this: http://www.phpinsider.com/php/code/SmartyPaginate/demo/

you notice that they have 100 records but they are only displaying ranges of up to 40 items. and when you click on range [31-40], range [1-10] disapears and a new range is printed which is [41-50].. Can anyone please help me achieve this. At the moment all my ranges are being being display like this [1-10] [11-20] .. .. .. .. .. .. [941-950], how can I display only four ranges per time?
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Sun Sep 30, 2012 10:57 pm    Post subject: Reply with quote

This is what that template is doing:

Code:
{paginate_first} {paginate_prev} {paginate_middle page_limit="4"} {paginate_next} {paginate_last}
Back to top
View user's profile Send private message Visit poster's website
Tonata
Smarty Rookie


Joined: 28 Jun 2010
Posts: 5

PostPosted: Sun Sep 30, 2012 11:02 pm    Post subject: Reply with quote

Thanks a million, you gave me a lot of hours of sleep..
Back to top
View user's profile Send private message
Tonata
Smarty Rookie


Joined: 28 Jun 2010
Posts: 5

PostPosted: Sun Sep 30, 2012 11:03 pm    Post subject: Reply with quote

How do I mark Solved?
mohrt wrote:
This is what that template is doing:

Code:
{paginate_first} {paginate_prev} {paginate_middle page_limit="4"} {paginate_next} {paginate_last}
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Sun Sep 30, 2012 11:13 pm    Post subject: Reply with quote

You should be able to edit the subject to mark solved. The README that comes with SmartyPaginate says this:

Code:
The page_limit attribute sets the maximum number of page groupings to display (if you have too many pages, limit the display with this.)
Back to top
View user's profile Send private message Visit poster's website
tdan
Smarty Rookie


Joined: 27 Mar 2015
Posts: 8

PostPosted: Wed Apr 29, 2015 4:54 am    Post subject: Can we adapt martypaginate files listing no database Reply with quote

Hello

Can we adapt martypaginate to a file listing of an image directory?

Do not use a database.

My listing directory code:

php:

Code:
<?php
  function liste($l){
    if ($handle = opendir($l)) {
      while (false !== ($entry = readdir($handle))) {
        if ($entry != "." && $entry != "..") {
          $la[] = $entry;
        }
      }
  closedir($handle);
    }
  return $la;
  }

$i = liste('./web/img/img');
$smarty->assign('i', $i);
?>


template:

Code:
{foreach from=$i item=ll}
   <img width="50" src="./web/img/tns/{$ll}">
{/foreach}
Back to top
View user's profile Send private message
tdan
Smarty Rookie


Joined: 27 Mar 2015
Posts: 8

PostPosted: Wed Apr 29, 2015 6:40 am    Post subject: [Resolu] Reply with quote

I solved the problem by replacing range () by my code in your function:

Code:
function get_db_results() {
   
function liste($l){
  if ($handle = opendir($l)) {
    while (false !== ($entry = readdir($handle))) {
      if ($entry != "." && $entry != "..") {
        $la[] = $entry;
      }
    }
  closedir($handle);
  }
return $la;
}

$_data = liste('./web/img/images/');

SmartyPaginate::setTotal(count($_data));
return array_slice($_data, SmartyPaginate::getCurrentIndex(),
SmartyPaginate::getLimit());
   
}


Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP