Page 1 of 1
Tags for pagination
Posted: Mon Nov 22, 2004 3:50 pm
by calguy1000
Hi Wishy
What tags should I use for the pagination markers (prev, next, total pages, etc).... couldn't find anything well marked in the style.css in the admin directory.
sorry, no IRC access at the office
Tags for pagination
Posted: Sun Dec 12, 2004 2:46 pm
by Shannon
new install of 7.3 and a fresh database... In the admin section on most links I get Fatal error: Call to undefined function: pagination() in /home/*****/public_html/admin/listgroups.php on line 33
Any ideas anyone? I am stumped...

Thank you,
Shannon
Solution for pagination
Posted: Sun Jan 23, 2005 1:54 pm
by 100rk
I changed implemetation of function pagination(..) in file 'page.functions.php' from
Code: Select all
/**
* Creates a string containing links to all the pages.
* @param page - the current page to display
* @param totalrows - the amount of items being listed
* @param limit - the amount of items to list per page
* @return a string containing links to all the pages (ex. next 1,2 prev)
*/
function pagination($page, $totalrows, $limit)
{
$page_string = "";
$from = ($page * $limit) - $limit;
$numofpages = $totalrows / $limit;
if ($numofpages > 1)
{
if($page != 1)
{
$pageprev = $page-1;
$page_string .= "<a href=\"".$_SERVER['PHP_SELF']."?page=$pageprev\">".lang('previous')."</a> ";
}
else
{
$page_string .= lang('previous')." ";
}
for($i = 1; $i <= $numofpages; $i++)
{
if($i == $page)
{
$page_string .= $i." ";
}
else
{
$page_string .= "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
}
}
if(($totalrows % $limit) != 0)
{
if($i == $page)
{
$page_string .= $i." ";
}
else
{
$page_string .= "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
}
}
if(($totalrows - ($limit * $page)) > 0)
{
$pagenext = $page+1;
$page_string .= "<a href=\"".$_SERVER['PHP_SELF']."?page=$pagenext\">".lang('next')."</a>";
}
else
{
$page_string .= lang('next')." ";
}
}
return $page_string;
}
to
Code: Select all
/**
* Creates a string containing links to all the pages.
* @param page - the current page to display
* @param totalrows - the amount of items being listed
* @param limit - the amount of items to list per page
* @param params - additional params for href - array of strings
* @return a string containing links to all the pages (ex. next 1,2 prev)
*/
function pagination($page, $totalrows, $limit, $params="")
{
$added_params = "";
if (is_array($params)) {
foreach ($params as $param) {
$added_params .= "&".$param;
}
}
$page_string = "";
$from = ($page * $limit) - $limit;
$numofpages = $totalrows / $limit;
if ($numofpages > 1)
{
if($page != 1)
{
$pageprev = $page-1;
$page_string .= "<a href=\"".$_SERVER['PHP_SELF']."?page=".$pageprev.$added_params."\">".lang('previous')."</a> ";
}
else
{
$page_string .= lang('previous')." ";
}
for($i = 1; $i <= $numofpages; $i++)
{
if($i == $page)
{
$page_string .= $i." ";
}
else
{
$page_string .= "<a href=\"".$_SERVER['PHP_SELF']."?page=".$i.$added_params."\">$i</a> ";
}
}
if(($totalrows % $limit) != 0)
{
if($i == $page)
{
$page_string .= $i." ";
}
else
{
$page_string .= "<a href=\"".$_SERVER['PHP_SELF']."?page=".$i.$added_params."\">$i</a> ";
}
}
if(($totalrows - ($limit * $page)) > 0)
{
$pagenext = $page+1;
$page_string .= "<a href=\"".$_SERVER['PHP_SELF']."?page=".$pagenext.$added_params."\">".lang('next')."</a>";
}
else
{
$page_string .= lang('next')." ";
}
}
return $page_string;
}
So, I can use this function like at file 'admin/adminlog.php', but (for example) with last parameter array('module=XY').
Caution for newbies: character '&' is added automatically.
Post scriptum
Posted: Sun Jan 23, 2005 1:59 pm
by 100rk
Of course, I speak ONLY about pagination in admin interface - if You want use this solution for pagination at Your webpages, You have to change parameter $config["query_var"] in file 'config.php' to another one

Re: Tags for pagination
Posted: Mon Aug 08, 2005 7:37 am
by mo
hi,
how can i do this for pagination at my web pages then? i duno about php much. if you can help me w/example. i appreciate it.
thanks,
mo
Re: Tags for pagination
Posted: Mon Aug 08, 2005 9:40 am
by 100rk
mo wrote:
how can i do this for pagination at my web pages then?
I think every PHP developer have his own way - whole problem is only about SQL statement SELECT and its part LIMIT. In case function 'pagination()' You are limited by it's parameter 'page', so if You have default install of CMSMS (no mod_rewrite, no changes in page variable), You can not use it in public interface.
I am using class SmartyPaginate in my Smarty-related projects, because this class is able to do almost all pagination-work for You (Your choice of pagination variable, possibility of more then one pagination bar at one page etc). For documentation, examples, demo and download see
http://www.phpinsider.com/php/code/SmartyPaginate/.
Of course, if You do not like SmartyPaginate output for pagination, there is plenty of smarty variables of this class for creation Your own pagination bar - just read whole documentation of this class. IMHO it is very usable.
Re: Tags for pagination
Posted: Mon Aug 08, 2005 11:04 am
by mo
thank you.
oh man, this is too difficult for me—i'm just a designer and know basic html/css. i'm just trying to do my portfolio website w/CMS. which i have very little knowledge about. and all i wanna do is to make the News pages w/paging. too bad, i'm not a program developer:(
Re: Tags for pagination
Posted: Mon Aug 08, 2005 11:20 am
by 100rk
mo wrote:
all i wanna do is to make the News pages w/paging
I am not pretty sure, what it means

- but You can organize Your News items into categories, every category can become on other page and You can define how much items (of news in this category) You want to display - example from Help of New module: {cms_module module="news" number="5" category="beer"}
And if You will combine this simple trick with user contributed plugin 'Improved version of cms_selflink' (download here:
http://wiki.cmsmadesimple.org/tiki-inde ... ed+Plugins, forum topic here:
http://forum.cmsmadesimple.org/index.ph ... 112.0.html), You will propably obtain almost all what You want - this plugin allows automatically create links 'previous page' and 'next page'.