PHP Report Maker generates your Pagination style based on the setting you chose from PHP Report Maker application; either using the drop down style or link of number style. In addition, either using top, bottom, or top and bottom position. Unfortunately, you have to choose one of those two or three options. If you want to switch from one to another style, then you have to re-generate your script files. Besides that, you have to define the value of the Page Size from PHP Report Maker application. In other words, there are some preferences that still not provided from the configuration file.
This following customization will solve those problems above by adding some constants in configuration file. You will be able to change the settings based on your choice by simply adjusting the related constants in that configuration file. This modification will give you the flexibility and the ability as following:
- The ability to use the pagination style by simply adjusting the related constant in your configuration (ewrcfg5.php) file, so that you will be able to switch it from one to another without having to re-generate your script files.
- The ability to define the pagination position; whether only at the top of the page, only at the bottom of the page, or at the both top and bottom of the page, by setting the related constant in the configuration file, so that you will be able to switch it from one to another without having to re-generate your script files.
- The ability to define the values of the page size in a string format with comma separated between the values, such as: “1, 5, 10, 15, 20″ from the related constant in your configuration file. It means that user will be able to switch the page size based on those five option values you defined. This will make you easier to define with your own values from the configuration file anytime you want.
- The ability to define the maximum selected groups your user can choose from your configuration file. For example, from the five options above, you should set this maximum selected groups value to 20. This will be useful whenever you want to prevent your user displaying the groups per page exceed 20 groups per page from the related parameter in the URL, then your system will automatically limit to 20 groups per page. Generally, this will limit the bandwidth usage of your web application. Does it sound a little smart, huh?
- The ability to define the default maximum groups per page when users load the list page, by setting it up from the related constant in the configuration file. This default constant value is derived from the default setting in your PHP Report Maker application. Of course you can define with your own value from the configuration file.
- The ability whether to display the page number if the maximum groups per page not over the page size or not by setting up the related constant in your configuration file. This will be useful if you don’t want to display the page number one whenever there is only one page.
- Switch the position of Page Size from the most right to the most left of your pagination style. It does more make sense to show the page size first, and then show the page navigation afterwards. This will make your users easier to select the maximum groups per page first, and then they will know how many pages based on that maximum groups per page value, following with the information of displaying from groups number x to y.
In addition to customize PHP Report Maker template file, then the following modification will synchronize the pagination settings in report pages that generated by PHP Report Maker so it will look similar with the pagination in web applications that generated by PHPMaker. Please note that there is the different term of "record(s)" between PHPMaker and PHP Report Maker. In PHPMaker, we called it with "record(s)" whereas in PHP Report Maker, we called it with "group(s)".
All we have to do is customizing PHP Report Maker template files. In other words, we will not modify the generated script files.
[hidepost]
-
Open your \Script\rpt-config.php file, and find this code:
<!--## If PROJ.AppCompat And PROJ.AppCompatVersion >= 9 Then ##-->
before that line, please insert the following code:
// Begin of modification Pagination, by Masino Sinaga, June 23, 2012 define("EWRPT_PAGINATION_STYLE", <!--##=PROJ.PagerStyle##-->, TRUE); // Whether to use drop down selection (2) or numeric link (1) for pagination style define("EWRPT_PAGINATION_POSITION", 3, TRUE); // 1 = Top, 2 = Bottom, 3 = Top and Bottom define("EWRPT_TABLE_SELECTABLE_GRP_PER_PAGE_LIST", "1,2,3,5,10,15,20,50,100", TRUE); // Selectable groups per page list define("EWRPT_TABLE_GROUPPERPAGE_VALUE", 3, TRUE); // Default groups per page define("EWRPT_TABLE_MAXIMUM_SELECTED_GROUPS", 150, TRUE); // Maximum selected groups per page define("EWRPT_SHOW_PAGENUM_IF_REC_NOT_OVER_PAGESIZE", FALSE, TRUE); // Whether to show or hide the pagenumber if groups not over pagesize. Set the second parameter to FALSE if you want to hide the pagenumber, otherwise set to TRUE in order to always show the pagenumber. // End of modification Pagination, by Masino Sinaga, June 23, 2012
-
Open your \Script\rpt-pager.php file, and then replace (yes, replace!) all of the content of that file (Warning: Backup your file before doing this step!):
<!--##session phppager##--> <!--## 'If TABLE.TblReportType = "list" Then If TABLE.TblType <> "REPORT" Then sItem = "<?php echo $ReportLanguage->Phrase(""Record""); ?>" sItemsPerPage = "<?php echo $ReportLanguage->Phrase(""RecordsPerPage""); ?>" Else sItem = "<?php echo $ReportLanguage->Phrase(""Group""); ?>" sItemsPerPage = "<?php echo $ReportLanguage->Phrase(""GroupsPerPage""); ?>" End If sImageFolder = ew_FolderPath("_images") & "/" iAnonymous = TABLE.TblAnonymous bAnonymousList = CBool(iAnonymous And 8) ##--> <form action="<!--##=sCurrentFileName##-->" name="ewpagerform" id="ewpagerform" class="msPagination"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td style="white-space: nowrap;"> <?php if (EWRPT_PAGINATION_STYLE==1) { ?> <span class="phpreportmaker"> <?php if (!isset($Pager)) $Pager = new crNumericPager($<!--##=sPageObj##-->->StartGrp, $<!--##=sPageObj##-->->DisplayGrps, $<!--##=sPageObj##-->->TotalGrps, $<!--##=sPageObj##-->->GrpRange) ?> <?php if ($Pager->RecordCount > 0) { ?> <!--## If sGrpPerPageList <> "" Then arrGrpPerPage = split(sGrpPerPageList,",") ##--> <?php if ($<!--##=sPageObj##-->->TotalGrps > 0) { ?> <span class="phpreportmaker"><!--##=sItemsPerPage##--> <select name="<?php echo EWRPT_TABLE_GROUP_PER_PAGE; ?>" onchange="this.form.submit();"> <?php $sGrpPerPageList = explode(',',EWRPT_TABLE_SELECTABLE_GRP_PER_PAGE_LIST); foreach ($sGrpPerPageList as $a) { $thisDisplayGrps = $a; if ($thisDisplayGrps > 0 ) { $thisValue = $thisDisplayGrps; ?> <option value="<?php echo $thisDisplayGrps; ?>"<?php if ($<!--##=sPageObj##-->->DisplayGrps == $thisValue) echo " selected=\"selected\"" ?>><?php echo $thisDisplayGrps; ?></option> <?php } else { ?> <option value="ALL"<?php if ($<!--##=sTblVar##-->->getGroupPerPage() == -1) echo " selected=\"selected\"" ?>><!--##@AllRecords##--></option> <?php } } ?> </select> </span> <?php } ?> <!--## End If ##--> <?php if ($Pager->FirstButton->Enabled) { ?> <a href="<!--##=sCurrentFileName##-->?start=<?php echo $Pager->FirstButton->Start ?>"><b><!--##@PagerFirst##--></b></a> <?php } ?> <?php if ($Pager->PrevButton->Enabled) { ?> <a href="<!--##=sCurrentFileName##-->?start=<?php echo $Pager->PrevButton->Start ?>"><b><!--##@PagerPrevious##--></b></a> <?php } ?> <?php foreach ($Pager->Items as $PagerItem) { ?> <?php if ($PagerItem->Enabled) { ?><a href="<!--##=sCurrentFileName##-->?start=<?php echo $PagerItem->Start ?>"><?php } ?><b><?php echo $PagerItem->Text ?></b><?php if ($PagerItem->Enabled) { ?></a><?php } ?> <?php } ?> <?php if ($Pager->NextButton->Enabled) { ?> <a href="<!--##=sCurrentFileName##-->?start=<?php echo $Pager->NextButton->Start ?>"><b><!--##@PagerNext##--></b></a> <?php } ?> <?php if ($Pager->LastButton->Enabled) { ?> <a href="<!--##=sCurrentFileName##-->?start=<?php echo $Pager->LastButton->Start ?>"><b><!--##@PagerLast##--></b></a> <?php } ?> <?php if ($Pager->ButtonCount > 0) { ?> <?php } ?> <!--##@Group##--> <?php echo $Pager->FromIndex ?> <!--##@To##--> <?php echo $Pager->ToIndex ?> <!--##@Of##--> <?php echo $Pager->RecordCount ?> <?php } else { ?> <!--## If bUserLevel And Not bAnonymousList Then ##--> <?php if (($Security->CurrentUserLevel() & EWRPT_ALLOW_LIST) == EWRPT_ALLOW_LIST) { ?> <!--## End If ##--> <?php if ($<!--##=sPageObj##-->->Filter == "0=101") { ?> <!--##@EnterSearchCriteria##--> <?php } else { ?> <!--##@NoRecord##--> <?php } ?> <!--## If bUserLevel And Not bAnonymousList Then ##--> <?php } else { ?> <!--##@NoPermission##--> <?php } ?> <!--## End If ##--> <?php } ?> </span> <?php } elseif (EWRPT_PAGINATION_STYLE==2) { ?> <?php if (!isset($Pager)) $Pager = new crPrevNextPager($<!--##=sPageObj##-->->StartGrp, $<!--##=sPageObj##-->->DisplayGrps, $<!--##=sPageObj##-->->TotalGrps) ?> <?php if ($Pager->RecordCount > 0) { ?> <table border="0" cellspacing="0" cellpadding="0"> <tr> <!--## If sGrpPerPageList <> "" Then arrGrpPerPage = split(sGrpPerPageList,",") ##--> <?php if ($<!--##=sPageObj##-->->TotalGrps > 0) { ?> <td align="right" style="vertical-align: top; white-space: nowrap;"><span class="phpreportmaker"><!--##=sItemsPerPage##--> <select name="<?php echo EWRPT_TABLE_GROUP_PER_PAGE; ?>" onchange="this.form.submit();"> <?php $sGrpPerPageList = explode(',',EWRPT_TABLE_SELECTABLE_GRP_PER_PAGE_LIST); foreach ($sGrpPerPageList as $a) { $thisDisplayGrps = $a; if ($thisDisplayGrps > 0 ) { $thisValue = $thisDisplayGrps; ?> <option value="<?php echo $thisDisplayGrps; ?>"<?php if ($<!--##=sPageObj##-->->DisplayGrps == $thisValue) echo " selected=\"selected\"" ?>><?php echo $thisDisplayGrps; ?></option> <?php } else { ?> <option value="ALL"<?php if ($<!--##=sTblVar##-->->getGroupPerPage() == -1) echo " selected=\"selected\"" ?>><!--##@AllRecords##--></option> <?php } } ?> </select> </span></td> <td style="white-space: nowrap;"> </td> <?php } ?> <!--## End If ##--> <?php if (($Pager->PageCount==1) && ($Pager->CurrentPage == 1) ) { ?> <?php if (EWRPT_SHOW_PAGENUM_IF_REC_NOT_OVER_PAGESIZE) { ?> <td><span class="phpreportmaker"><!--##@Page##--> </span></td> <!--first page button--> <?php if ($Pager->FirstButton->Enabled) { ?> <td><a href="<!--##=sCurrentFileName##-->?start=<?php echo $Pager->FirstButton->Start ?>"><img src="<!--##=sImageFolder##-->first.gif" alt="<!--##@PagerFirst##-->" width="16" height="16" border="0"></a></td> <?php } else { ?> <td><img src="<!--##=sImageFolder##-->firstdisab.gif" alt="<!--##@PagerFirst##-->" width="16" height="16" border="0"></td> <?php } ?> <!--previous page button--> <?php if ($Pager->PrevButton->Enabled) { ?> <td><a href="<!--##=sCurrentFileName##-->?start=<?php echo $Pager->PrevButton->Start ?>"><img src="<!--##=sImageFolder##-->prev.gif" alt="<!--##@PagerPrevious##-->" width="16" height="16" border="0"></a></td> <?php } else { ?> <td><img src="<!--##=sImageFolder##-->prevdisab.gif" alt="<!--##@PagerPrevious##-->" width="16" height="16" border="0"></td> <?php } ?> <!--current page number--> <td><input type="text" name="pageno" id="pageno" value="<?php echo $Pager->CurrentPage ?>" size="4"></td> <!--next page button--> <?php if ($Pager->NextButton->Enabled) { ?> <td><a href="<!--##=sCurrentFileName##-->?start=<?php echo $Pager->NextButton->Start ?>"><img src="<!--##=sImageFolder##-->next.gif" alt="<!--##@PagerNext##-->" width="16" height="16" border="0"></a></td> <?php } else { ?> <td><img src="<!--##=sImageFolder##-->nextdisab.gif" alt="<!--##@PagerNext##-->" width="16" height="16" border="0"></td> <?php } ?> <!--last page button--> <?php if ($Pager->LastButton->Enabled) { ?> <td><a href="<!--##=sCurrentFileName##-->?start=<?php echo $Pager->LastButton->Start ?>"><img src="<!--##=sImageFolder##-->last.gif" alt="<!--##@PagerLast##-->" width="16" height="16" border="0"></a></td> <?php } else { ?> <td><img src="<!--##=sImageFolder##-->lastdisab.gif" alt="<!--##@PagerLast##-->" width="16" height="16" border="0"></td> <?php } ?> <td><span class="phpreportmaker"> <!--##@of##--> <?php echo $Pager->PageCount ?></span></td> </tr></table> </td> <td> </td> <td> <span class="phpreportmaker"><!--##@Group##--> <?php echo $Pager->FromIndex ?> <!--##@To##--> <?php echo $Pager->ToIndex ?> <!--##@Of##--> <?php echo $Pager->RecordCount ?></span> <?php } else { // Else of EWRPT_SHOW_PAGENUM_IF_REC_NOT_OVER_PAGESIZE ?> </tr></table> </td> <td> <span class="phpreportmaker"><!--##@Group##--> <?php echo $Pager->FromIndex ?> <!--##@To##--> <?php echo $Pager->ToIndex ?> <!--##@Of##--> <?php echo $Pager->RecordCount ?></span> <?php } // End of EWRPT_SHOW_PAGENUM_IF_REC_NOT_OVER_PAGESIZE ?> <?php } else { // Else of CurrentPage == 1 ?> <td><span class="phpreportmaker"><!--##@Page##--> </span></td> <!--first page button--> <?php if ($Pager->FirstButton->Enabled) { ?> <td><a href="<!--##=sCurrentFileName##-->?start=<?php echo $Pager->FirstButton->Start ?>"><img src="<!--##=sImageFolder##-->first.gif" alt="<!--##@PagerFirst##-->" width="16" height="16" border="0"></a></td> <?php } else { ?> <td><img src="<!--##=sImageFolder##-->firstdisab.gif" alt="<!--##@PagerFirst##-->" width="16" height="16" border="0"></td> <?php } ?> <!--previous page button--> <?php if ($Pager->PrevButton->Enabled) { ?> <td><a href="<!--##=sCurrentFileName##-->?start=<?php echo $Pager->PrevButton->Start ?>"><img src="<!--##=sImageFolder##-->prev.gif" alt="<!--##@PagerPrevious##-->" width="16" height="16" border="0"></a></td> <?php } else { ?> <td><img src="<!--##=sImageFolder##-->prevdisab.gif" alt="<!--##@PagerPrevious##-->" width="16" height="16" border="0"></td> <?php } ?> <!--current page number--> <td><input type="text" name="pageno" id="pageno" value="<?php echo $Pager->CurrentPage ?>" size="4"></td> <!--next page button--> <?php if ($Pager->NextButton->Enabled) { ?> <td><a href="<!--##=sCurrentFileName##-->?start=<?php echo $Pager->NextButton->Start ?>"><img src="<!--##=sImageFolder##-->next.gif" alt="<!--##@PagerNext##-->" width="16" height="16" border="0"></a></td> <?php } else { ?> <td><img src="<!--##=sImageFolder##-->nextdisab.gif" alt="<!--##@PagerNext##-->" width="16" height="16" border="0"></td> <?php } ?> <!--last page button--> <?php if ($Pager->LastButton->Enabled) { ?> <td><a href="<!--##=sCurrentFileName##-->?start=<?php echo $Pager->LastButton->Start ?>"><img src="<!--##=sImageFolder##-->last.gif" alt="<!--##@PagerLast##-->" width="16" height="16" border="0"></a></td> <?php } else { ?> <td><img src="<!--##=sImageFolder##-->lastdisab.gif" alt="<!--##@PagerLast##-->" width="16" height="16" border="0"></td> <?php } ?> <td><span class="phpreportmaker"> <!--##@of##--> <?php echo $Pager->PageCount ?></span></td> </tr></table> </td> <td> </td> <td> <span class="phpreportmaker"><!--##@Group##--> <?php echo $Pager->FromIndex ?> <!--##@To##--> <?php echo $Pager->ToIndex ?> <!--##@Of##--> <?php echo $Pager->RecordCount ?></span> <?php } // End of CurrentPage == 1 ?> <?php } else { ?> <!--## If bUserLevel And Not bAnonymousList Then ##--> <?php if (($Security->CurrentUserLevel() & EWRPT_ALLOW_LIST) == EWRPT_ALLOW_LIST) { ?> <!--## End If ##--> <?php if ($<!--##=sPageObj##-->->Filter == "0=101") { ?> <span class="phpreportmaker"><!--##@EnterSearchCriteria##--></span> <?php } else { ?> <span class="phpreportmaker"><!--##@NoRecord##--></span> <?php } ?> <!--## If bUserLevel And Not bAnonymousList Then ##--> <?php } else { ?> <span class="phpreportmaker"><!--##@NoPermission##--></span> <?php } ?> <!--## End If ##--> <?php } // End of RecordCount > 0 ?> <?php } // End of Pagination Style ?> </td> </tr> </table> </form> <!--##/session##--> <?php <!--##session setupdisplaygrps##--> // Set up number of groups displayed per page function SetUpDisplayGrps() { global $<!--##=sTblVar##-->; global $ReportLanguage; $sWrk = @$_GET[EWRPT_TABLE_GROUP_PER_PAGE]; if ($sWrk > EWRPT_TABLE_MAXIMUM_SELECTED_GROUPS) { $sWrk = EWRPT_TABLE_MAXIMUM_SELECTED_GROUPS; $this->setMessage(str_replace("%t", EWRPT_TABLE_MAXIMUM_SELECTED_GROUPS, $ReportLanguage->Phrase("maximumgroupsperpage"))); } if ($sWrk <> "") { if (is_numeric($sWrk)) { $this->DisplayGrps = intval($sWrk); } else { if (strtoupper($sWrk) == "ALL") { // display all groups $this->DisplayGrps = -1; } else { $this->DisplayGrps = EWRPT_TABLE_GROUPPERPAGE_VALUE; // <!--##=iGrpPerPage##-->; // Non-numeric, load default } } $<!--##=sTblVar##-->->setGroupPerPage($this->DisplayGrps); // Save to session // Reset start position (reset command) $this->StartGrp = 1; $<!--##=sTblVar##-->->setStartGroup($this->StartGrp); } else { if ($<!--##=sTblVar##-->->getGroupPerPage() <> "") { $this->DisplayGrps = $<!--##=sTblVar##-->->getGroupPerPage(); // Restore from session } else { $this->DisplayGrps = EWRPT_TABLE_GROUPPERPAGE_VALUE; // <!--##=iGrpPerPage##-->; // Load default } } } <!--##/session##--> ?>
-
Open your \Script\rpt-summary.php file, and find this code:
<!--## If bTopPageLink Then ##--> <!--##=sExpStart##--> <div class="ewGridUpperPanel"> <!--##include rpt-pager.php/phppager##--> </div> <!--##=sExpEnd##--> <!--## End If ##-->
then replace it with the following code:
<?php // Begin of modification Pagination, by Masino Sinaga, June 23, 2012 ?> <?php if ( (EWRPT_PAGINATION_POSITION==1) || (EWRPT_PAGINATION_POSITION==3) ) { ?> <?php // End of modification Pagination, by Masino Sinaga, June 23, 2012 ?> <!--##=sExpStart##--> <div class="ewGridUpperPanel"> <!--##include rpt-pager.php/phppager##--> </div> <!--##=sExpEnd##--> <?php // Begin of modification Pagination, by Masino Sinaga, June 23, 2012 ?> <?php } <?php // End of modification Pagination, by Masino Sinaga, June 23, 2012 ?>
-
Still in that \Script\rpt-summary.php file, find again this code:
<!--## If bBottomPageLink Then ##--> <!--## If bTopPageLink Then ##--> <?php if ($<!--##=sPageObj##-->->TotalGrps > 0) { ?> <!--## End If ##--> <!--##=sExpStart##--> <div class="ewGridLowerPanel"> <!--##include rpt-pager.php/phppager##--> </div> <!--##=sExpEnd##--> <!--## If bTopPageLink Then ##--> <?php } ?> <!--## End If ##--> <!--## End If ##-->
then replace it with the following code:
<?php // Begin of modification Pagination, by Masino Sinaga, June 23, 2012 ?> <?php if ( (EWRPT_PAGINATION_POSITION==2) || (EWRPT_PAGINATION_POSITION==3) ) { ?> <?php // End of modification Pagination, by Masino Sinaga, June 23, 2012 ?> <?php if ($<!--##=sPageObj##-->->TotalGrps > 0) { ?> <!--##=sExpStart##--> <div class="ewGridLowerPanel"> <!--##include rpt-pager.php/phppager##--> </div> <!--##=sExpEnd##--> <?php } ?> <?php } ?> <?php // End of modification Pagination, by Masino Sinaga, June 23, 2012 ?>
[/hidepost]
Leave a Reply
You must be logged in to post a comment.