RE: [SMARTY] Re: Multiple page manager

From: Date: Mon, 10 Mar 2003 09:27:32 +0000
Subject: RE: [SMARTY] Re: Multiple page manager
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-8520@lists.php.net to get a copy of this message
Try using this one. Register it: $smarty->register_function("pagination", "smarty_function_pagination"); Usage looks like {pagination count=$per_page total_count=$total_count link="order=$smarty.get.order" start=$start separator="&nbsp;" next="<img alt='next page' src='images/greenarrow.gif' border='0' width='14' height='13'>" previous="<img alt='next page' src='images/greenarrow-left.gif' border='0' width='14' height='13'>"} Or (simplier) {pagination count=$per_page total_count=$total_count link="order=$smarty.get.order" start=$start separator="&nbsp;"} Feel free to ask * Smarty plugin * ------------------------------------------------------------- * Type: function * Name: pagination * Purpose: prints pagination * ------------------------------------------------------------- */ function smarty_function_pagination($params, &$this) { extract($params); /*$params[]: $totalCount = 1, $start = 0, $count = 10, $linkStr $separator = | $next $previous */ // if (count($params) != 4) { // $this->trigger_error("pagination: missing parameters"); // return; // } // initialization start empty($separator) ? $separator = "|" : $separator = $params[separator]; empty($next) ? $next = "Next" : $next = $params[next]; empty($previous) ? $previous = "Previous" : $previous = $params[previous]; // initialization end if (!isset($params[count]) || !isset($params[total_count])) { dump($params); $this->trigger_error("pagination: missing parameters"); return; } if (!empty($count)) { if (div_ost($total_count, $count) > 0) { $page_number = div_cil($total_count, $count) + 1; } else { $page_number = div_cil($total_count, $count); } // don't show anything if only one page if ($page_number > 1) { for ($i = 0; $i < $page_number; $i++) { if ($start == ($i * $count)) $arr[$i] = "<b>".($i + 1)."</b>"; else $arr[$i] = "<a href='?start=".($i * $count)."&".$link."'>".($i + 1)."</a>"; } $str .= join($arr, " ".$separator." "); if ($start >= $count) $str = "<a href='?start=".($start - $count)."&".$link."'>".$previous."</a> ".$separator." ".$str; if (($start + $count) < $total_count) $str = $str." ".$separator." <a href='?start=".($start + $count)."&".$link."'>".$next."</a>"; echo $str; } } //navigationBar ($total_count, $start, $count, $linkArr); } function div_cil($var, $n) { return floor($var / $n); } function div_ost($var, $n) { return ($var - (floor($var / $n) *$n)); } --------------- Ruslan Savchyshyn http://www.MagneticOne.com/ Web development and design services -----Original Message----- From: Jacques Jocelyn [mailto:jacques.jocelyn@free.fr] Sent: Monday, March 10, 2003 12:39 AM To: smarty-general@lists.php.net Subject: [SMARTY] Re: Multiple page manager Joscha, I am trying to adapt my current function to Smarty but it seems to be harder than expected (I am not familiar to smarty yet). do you have an example for this specific case ? thanks, Jacques "Joscha Feth" <joscha@feth.com> wrote in message news:20030309221105.85367.qmail@pb1.pair.com... > Jacques Jocelyn wrote: > > <a href=page.php?page1>page1</a> - <a > > href=page.php?page=2>page2</a> > > </body> > > use a section - you can not only give section an array, but also a number... > greets, > Joscha > > -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.smarty.general (#8520) next »