|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
gman Smarty Rookie
Joined: 27 Feb 2005 Posts: 5
|
Posted: Mon Feb 28, 2005 6:56 pm Post subject: |
|
|
Thanks for fixing the page [0] problem. I am still having problems. Using the latest CVS code. The second click after I click on a page higher than the midpoint of page_limit... then paginate seems to get "lost".
For instance, my page_limit is 10, my setLimit is 25, I get
[1][2][3][4][5][6][7][8][9][10]
if I click on 1-6, no problem. If I click on anything higher than 6, then things get screwey on the next click. My code is extremely simple. Here it is:
Template (test.tpl):
Code: | <br><br>
{* display pagination header *}
Showing {$paginate.limit} per page.<br>
Showing page {$paginate.last/$paginate.limit|ceil} of {$paginate.total/$paginate.limit|ceil}.<br>
Items {$paginate.first}-{$paginate.last} out of {$paginate.total} displayed.<br>
<br>
{* display pagination info *}
{paginate_first} {paginate_prev} {paginate_middle format="page" page_limit="10"} {paginate_next} {paginate_last}
<br>
<br>
{* display results *}
{section name=i loop=$results}
{$results[i]}<br>
{/section} |
PHP (test.php):
Code: | <?php
session_start();
require('/usr/local/lib/php/Smarty/Smarty.class.php');
require('/usr/local/lib/php/Smarty/SmartyPaginate.class.php');
$smarty = new Smarty();
SmartyPaginate::connect();
SmartyPaginate::setLimit(25);
$smarty->template_dir = '/wwwroot/smarty/templates';
$smarty->compile_dir = '/wwwroot/smarty/templates_c';
$smarty->cache_dir = '/wwwroot/smarty/cache';
$smarty->config_dir = '/wwwroot/smarty/configs';
$start = SmartyPaginate::getCurrentIndex();
$limit = SmartyPaginate::getLimit();
$data = range(1,10000);
$smarty->assign('results', array_slice($data, $start, $limit));
SmartyPaginate::setTotal(count($data));
SmartyPaginate::assign($smarty);
$smarty->display('test.tpl');
?> |
|
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Feb 28, 2005 7:43 pm Post subject: |
|
|
oops, my fault. Try CVS again. Thanks for testing |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Feb 28, 2005 8:00 pm Post subject: |
|
|
I also added the following to CVS:
{$paginate.page_current} {* the current page *}
{$paginate.page_total} {* the total number of pages *} |
|
Back to top |
|
gman Smarty Rookie
Joined: 27 Feb 2005 Posts: 5
|
Posted: Tue Mar 01, 2005 1:09 am Post subject: |
|
|
Beautiful! I just tried the latest version from CVS and it now works as expected.
Thanks!
|
|
Back to top |
|
darren.hoo Smarty n00b
Joined: 01 Mar 2005 Posts: 2 Location: Beijing,China
|
Posted: Tue Mar 01, 2005 11:46 am Post subject: |
|
|
great! morht.I have been looking for this for a long time!!! |
|
Back to top |
|
|
|
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
|