This topic is locked
[SOLVED]

 List Page - Next/Previous Buttons

6/28/2012 3:51:29 PM
PHPRunner General questions
E
electromotive author

What ways do you use to put Next and Previous page buttons on the List page pagination?

That's for moving just one list page at a time, just like on the bottom of the forum.

Sergey Kornilov admin 6/29/2012

tablename_list.php?goto=<page number> will take you to page <page number>.
Example:

echo "<a href='cars_list.php?goto=".($_SESSION["Cars_pagenumber"]+1)."'>Next</a>";


Table name is Cars, session variables are case sensitive.

E
electromotive author 6/30/2012

The following works on earlier PHPR versions, or on later versions with javascript disabled (or ajax pagination disabled):

  • In the Before Display event, add:



global $strTableName;

$_SESSION[$strTableName."_numpages"] = $xt->getvar("maxpages");


  • On the list page insert a PHP snippet for the Prev button. Use this code:



global $strTableName;

if ($_SESSION[$strTableName."_pagenumber"] > 1)

echo "<a href='".$strTableName."_list.php?goto=".($_SESSION[$strTableName."_pagenumber"]-1)."'>PrevPage</a>";


  • Insert a PHP snippet for the Next button. Use this code:



global $strTableName;

if ($_SESSION[$strTableName."_pagenumber"] < $_SESSION[$strTableName."_numpages"])

echo "<a href='".$strTableName."_list.php?goto=".($_SESSION[$strTableName."_pagenumber"]+1)."'>NextPage</a>";


I believe this works on more recent versions (6+) with javascript enabled, and uses ajax to refresh the grid.

It won't work if javascript or ajax pagination is disabled:

  • In the Before Display event, add:



global $strTableName;

if (!isset($_SESSION[$strTableName."_pagenumber"]) || $_SESSION[$strTableName."_pagenumber"] < 1)

$_SESSION[$strTableName."_pagenumber"] = 1;

$_SESSION[$strTableName."_numpages"] = $xt->getvar("maxpages");


  • On the list page insert a PHP snippet for the Prev button. Use this code:



global $strTableName;

if ($_SESSION[$strTableName."_pagenumber"] > 1)

echo "<a href='#' pageNum='".($_SESSION[$strTableName."_pagenumber"]-1)."' class='pag_n' style='TEXT-DECORATION: none;'>PrevPage</a>";


  • Insert a PHP snippet for the Next button. Use this code:



global $strTableName;

if ($_SESSION[$strTableName."_pagenumber"] < $_SESSION[$strTableName."_numpages"])

echo "<a href='#' pageNum='".($_SESSION[$strTableName."_pagenumber"]+1)."' class='pag_n' style='TEXT-DECORATION: none;'>NextPage</a>";



If you are clever you'll find a way of detecting if JS pagination is enabled, and select the correct statement