Hi,
Im creating some pagination with smarty...ive got the page numbers spitting out fine.....like so:
Code PHP://If there are no results then print a message saying so if(mysql_num_rows($query) == 0){ $tpl->assign("noresults", "1"); } //If we are not on page 1 then output a previous link if($page != 1) { $pageprev = $page - '1'; $tpl->assign('prev','1'); $tpl->assign('cat', $category); $tpl->assign("pageprev", $pageprev); $tpl->assign("limit", $limit); } //print a next button if there are enough results //there wouldnt be if there were ten rows, the limit was 2 and we were on page 2 // 10 - (2 x 5) = 0 if(($totalrows - ($limit * $page)) > 0) { $pagenext = $page + '1'; $tpl->assign('next','1'); $tpl->assign('cat', $category); $tpl->assign("pagenext", $pagenext); $tpl->assign("limit", $limit); } //Now build the page numbers $numofpages = ceil($totalrows / $limit); for($i = 1; $i <= $numofpages; $i++) { $pagingArray = array(); $pagingArray['pageNo'] = $i; $pagingArray['cat'] = $category; $tpl->append("pagingArray", $pagingArray); if($i == $page) { $tpl->assign("current", '1'); }
and the assocaited template code :
Code PHP:<ul class="paging"> {if $prev} <li><a href="results.php?category={$cat}&page={$pageprev}">Previous</a></li> {/if} {foreach from=$pagingArray item=i} {if $current} <li>{$i.page}</li> {/if} <li><a href="results.php?category={$i.cat}&page={$i.pageNo}">{$i.pageNo}</a></li> {/foreach} {if $next} <li><a href="results.php?category={$cat}&page={$pagenext}">Next</a></li> {/if} </ul>
Now, this all works dandy but the rpoblem comes when i want to diplsay just the page number and not a link for when im on the corresponsing page.....so if im on page 2 i dont want the 2 to be a link in the page number list...i just want it to be static....
Ive had a stab at it....the php code correct ( its the if $page = $i bit above)
but i dont know how to get it outputting in the template ( ive also tried to put it in the template but it doesnt work....how do i do this????/





Bookmarks