Insert pagination using TYPO3 pagebrowse
1) Define this function of pagebrowse
public function getListGetPageBrowser($numberOfPages)
{
// Get default configuration
$conf = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_pagebrowse_pi1.'];
//Modify this configuration
$conf += array( 'pageParameterName' => $this->prefixId . '|page', 'numberOfPages' => $numberOfPages,);
// Get page browser
$cObj = t3lib_div::makeInstance('tslib_cObj');
/* @var $cObj tslib_cObj */
$cObj->start(array(), '');
return $cObj->cObjGetSingle('USER', $conf);
}
2)Logic of pagination where query built
// pagination logic start
if(isset($_GET['tx_property_pi1']['page']))
$page=$_GET['tx_property_pi1']['page'];
else
$page=0;
$no_of_records = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
$i = $page*$this->records_per_page;
$paginationStart = $page*$this->records_per_page+1;
$paginationEnd = ($paginationStart+$this->records_per_page-1 <= $no_of_records)?$paginationStart+$this->records_per_page-1:$no_of_records;
$pagin = ceil($no_of_records/$this->records_per_page);
$count = 0;
$record = $paginationStart;
//logic for pagination over
3)Fetch results one by one using while loop (code that need to put after code of step2)
while(($count<$this->records_per_page) && ($i<$no_of_records))
{
mysql_data_seek($res,$i);
$row = mysql_fetch_array($res);
$i++;
$count++;
//Your code
}
//call function to display pagination
echo $this->getListGetPageBrowser($pagin);
Thats it!!
1) Define this function of pagebrowse
public function getListGetPageBrowser($numberOfPages)
{
// Get default configuration
$conf = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_pagebrowse_pi1.'];
//Modify this configuration
$conf += array( 'pageParameterName' => $this->prefixId . '|page', 'numberOfPages' => $numberOfPages,);
// Get page browser
$cObj = t3lib_div::makeInstance('tslib_cObj');
/* @var $cObj tslib_cObj */
$cObj->start(array(), '');
return $cObj->cObjGetSingle('USER', $conf);
}
2)Logic of pagination where query built
// pagination logic start
if(isset($_GET['tx_property_pi1']['page']))
$page=$_GET['tx_property_pi1']['page'];
else
$page=0;
$no_of_records = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
$i = $page*$this->records_per_page;
$paginationStart = $page*$this->records_per_page+1;
$paginationEnd = ($paginationStart+$this->records_per_page-1 <= $no_of_records)?$paginationStart+$this->records_per_page-1:$no_of_records;
$pagin = ceil($no_of_records/$this->records_per_page);
$count = 0;
$record = $paginationStart;
//logic for pagination over
3)Fetch results one by one using while loop (code that need to put after code of step2)
while(($count<$this->records_per_page) && ($i<$no_of_records))
{
mysql_data_seek($res,$i);
$row = mysql_fetch_array($res);
$i++;
$count++;
//Your code
}
//call function to display pagination
echo $this->getListGetPageBrowser($pagin);
Thats it!!
No comments:
Post a Comment