PHPMaker generates your Pagination style (generally, in the page that displays the list of records or record view) based on the setting you chose from PHPMaker application; whether you want to use the drop down style, or link of number style. Unfortunately, you have to choose one of those two 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 PHPMaker application. In other words, there are some preferences that still not provided in the configuration file.
This following customization will solve those problems above, and 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 (ewcfg9.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 records your user can choose from your configuration file. For example, from the five options above, you should set this maximum selected records value to 20. This will be useful whenever you want to prevent your user displaying the records per page exceed 20 records per page from the related parameter in the URL, then your system will automatically limit to 20 records 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 record 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 PHPMaker 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 record 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 records per page first, and then they will know how many pages based on that maximum records per page value, following with the information of displaying from record number x to y.
- If you disable Use global settings from the Table setup, then the settings that belong to the table will still being used, such as the pagination position, list of record numbers, and default page size. In other words, this customization will also handle the possibility of using the table setting instead of the global setting that derived from the constants value in the configuration file.
All we have to do is customizing PHPMaker template files. In other words, we will not modify the generated script files.
Updated on May 29, 2012: This customization has been implemented in PHPMaker version 9.0.2, it matches to each other, and as a result, it works properly.
Updated on July 21, 2012: This customization has been implemented in PHPMaker version 9.0.3, it matches to each other, and as a result, it works properly.
Updated on September 4, 2012: This customization has been implemented in PHPMaker version 9.0.4, it matches to each other, and as a result, it works properly.
Updated on November 28, 2012: This customization has been implemented in PHPMaker version 9.1.0, it matches to each other, and as a result, it works properly.
Updated on February 9, 2013: This customization has been implemented in PHPMaker version 9.2.0, it matches to each other, and as a result, it works properly.
Updated on June 17, 2013: This customization below has been handled by using MasinoFixedWidthSite extension. You don’t need to implement the customization below if you use my extensions together with the original PHPMaker Template and Extension files.
[hidepost]
-
Open your C:\Program Files\PHPMaker 9\languages\english.xml file, and find this code:
</global>
before that line, please insert the following code:
<phrase id="MaximumRecordsPerPage" value="Maximum %t records per page."/> -
Do the same way with your another .xml language file. For example, I am also using Indonesian, so I add this following code as the translation of that phrase above in my indonesian.xml file:
<phrase id="MaximumRecordsPerPage" value="Maksimum %t record per halaman."/> -
Open your \Script\ewcfg.php file, and find this code:
// General
before that line, please insert the following code:
// Begin of modification Customize Navigation/Pager Panel, by Masino Sinaga, May 2, 2012 define("MS_PAGINATION_STYLE", <!--##=PROJ.PagerStyle##-->, TRUE); // Whether to use drop down selection (2) or numeric link (1) for pagination style <!--## bTopPageLink = PROJ.TopPageLink; bBottomPageLink = PROJ.BottomPageLink; if (bTopPageLink && bBottomPageLink) { bPagingPosition = 3; // Top and Bottom } else if (!bTopPageLink && bBottomPageLink) { bPagingPosition = 2; // Bottom only } else if (bTopPageLink && !bBottomPageLink) { bPagingPosition = 1; // Top only } else { // default: Bottom only bPagingPosition = 2; } ##--> define("MS_PAGINATION_POSITION", <!--##=bPagingPosition##-->, TRUE); // 1 = Top, 2 = Bottom, 3 = Top and Bottom define("MS_TABLE_SELECTABLE_REC_PER_PAGE_LIST", "<!--##=PROJ.RecPerPageList##-->", TRUE); // Selectable records per page list, derived from PHPMaker -> PHP -> List/View Page Options (Global) -> Selectable page sizes define("MS_TABLE_MAXIMUM_SELECTED_RECORDS", 20, TRUE); // Maximum selected records per page define("MS_TABLE_RECPERPAGE_VALUE", <!--##=PROJ.RecPerPage##-->, TRUE); // Default records per page value define("MS_SHOW_PAGENUM_IF_REC_NOT_OVER_PAGESIZE", TRUE, TRUE); // Whether to show or hide the pagenumber if records 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 Customize Navigation/Pager Panel, by Masino Sinaga, May 2, 2012 -
Open your \Script\list-script.php file, and find this code:
var $DisplayRecs = <!--##=iRecPerPage##-->;then replace it with the following code:
// Begin of modification Customize Navigation/Pager Panel, by Masino Sinaga, May 2, 2012 <!--## if (TABLE.TblUseGlobal) { ##--> var $DisplayRecs = MS_TABLE_RECPERPAGE_VALUE; <!--## } else { ##--> var $DisplayRecs = <!--##=iRecPerPage##-->; <!--## } ##--> // End of modification Customize Navigation/Pager Panel, by Masino Sinaga, May 2, 2012 -
Still in your \Script\list-script.php file, find again this code:
$this->DisplayRecs = <!--##=iRecPerPage##-->; // Load default
then replace it with the following code:
// Begin of modification Customize Navigation/Pager Panel, by Masino Sinaga, May 2, 2012 <!--## if (TABLE.TblUseGlobal) { ##--> $this->DisplayRecs = MS_TABLE_RECPERPAGE_VALUE; // Load default <!--## } else { ##--> $this->DisplayRecs = <!--##=iRecPerPage##-->; // Load default <!--## } ##--> // End of modification Customize Navigation/Pager Panel, by Masino Sinaga, May 2, 2012 -
Still in your \Script\list-script.php file, find again this code:
<!--## if (bTopPageLink) { ##--> <!--##=sExpStart##--> <div class="ewGridUpperPanel"> <?php if ($<!--##=gsTblVar##-->->CurrentAction <> "gridadd" && $<!--##=gsTblVar##-->->CurrentAction <> "gridedit") { ?> <!--##include pager.php/pager##--> <?php } ?> <!--##include list-script-inline.php/optionhtml##--> </div> <!--##=sExpEnd##--> <!--## } ##-->then replace it with the following code:
<?php // Begin of modification Customize Navigation/Pager Panel, by Masino Sinaga, May 2, 2012 ?> <!--## if (TABLE.TblUseGlobal) { ##--> <?php if ( (MS_PAGINATION_POSITION==1) || (MS_PAGINATION_POSITION==3) ) { ?> <!--##=sExpStart##--> <div class="ewGridUpperPanel"> <?php if ($<!--##=gsTblVar##-->->CurrentAction <> "gridadd" && $<!--##=gsTblVar##-->->CurrentAction <> "gridedit") { ?> <!--##include pager.php/pager##--> <?php } ?> <!--##include list-script-inline.php/optionhtml##--> </div> <!--##=sExpEnd##--> <?php } ?> <!--## } else { ##--> <!--## if (bTopPageLink || (bTopPageLink && bBottomPageLink)) { ##--> <!--##=sExpStart##--> <div class="ewGridUpperPanel"> <?php if ($<!--##=gsTblVar##-->->CurrentAction <> "gridadd" && $<!--##=gsTblVar##-->->CurrentAction <> "gridedit") { ?> <!--##include pager.php/pager##--> <?php } ?> <!--##include list-script-inline.php/optionhtml##--> </div> <!--##=sExpEnd##--> <!--## } ##--> <!--## } ##--> <?php // End of modification Customize Navigation/Pager Panel, by Masino Sinaga, May 2, 2012 ?> -
Still in the \Script\list-script.php file, find again this code:
<!--## if (bTopPageLink && bBottomPageLink) { ##--> <?php if ($<!--##=sPageObj##-->->TotalRecs > 0) { ?> <!--## } ##--> <!--## if (bBottomPageLink || !bTopPageLink) { ##--> <!--##=sExpStart##--> <div class="ewGridLowerPanel"> <!--## if (bBottomPageLink) { ##--> <?php if ($<!--##=gsTblVar##-->->CurrentAction <> "gridadd" && $<!--##=gsTblVar##-->->CurrentAction <> "gridedit") { ?> <!--##include pager.php/pager##--> <?php } ?> <!--## } ##--> <!--##include list-script-inline.php/optionhtml##--> </div> <!--##=sExpEnd##--> <!--## } ##--> <!--## if (bTopPageLink && bBottomPageLink) { ##--> <?php } ?> <!--## } ##--> <!--## } ##-->then replace it with the following code:
<?php // Begin of modification Customize Navigation/Pager Panel, by Masino Sinaga, May 2, 2012 ?> <!--## if (TABLE.TblUseGlobal) { ##--> <?php if ( (MS_PAGINATION_POSITION==2) || (MS_PAGINATION_POSITION==3) ) { ?> <?php if ($<!--##=sPageObj##-->->TotalRecs > 0) { ?> <!--##=sExpStart##--> <div class="ewGridLowerPanel"> <?php if ($<!--##=gsTblVar##-->->CurrentAction <> "gridadd" && $<!--##=gsTblVar##-->->CurrentAction <> "gridedit") { ?> <!--##include pager.php/pager##--> <?php } ?> <!--##include list-script-inline.php/optionhtml##--> </div> <!--##=sExpEnd##--> <?php } ?> <?php } ?> <!--## } else { ##--> <!--## if (bBottomPageLink || (bTopPageLink && bBottomPageLink)) { ##--> <?php if ($<!--##=sPageObj##-->->TotalRecs > 0) { ?> <!--##=sExpStart##--> <div class="ewGridLowerPanel"> <?php if ($<!--##=gsTblVar##-->->CurrentAction <> "gridadd" && $<!--##=gsTblVar##-->->CurrentAction <> "gridedit") { ?> <!--##include pager.php/pager##--> <?php } ?> <!--##include list-script-inline.php/optionhtml##--> </div> <!--##=sExpEnd##--> <?php } ?> <!--## } ##--> <!--## } ##--> <!--## } ##--> <?php // End of modification Customize Navigation/Pager Panel, by Masino Sinaga, May 2, 2012 ?> -
Open your \Script\view-script.php file, and find this code:
<!--## if (bDetailViewPaging && bTopPageLink) { ##--> <!--##=sExpStart##--> <!--##include pager.php/pager##--> <br /> <!--##=sExpEnd##--> <!--## } ##-->then replace it with the following code:
<?php // Begin of modification Customize Navigation/Pager Panel, by Masino Sinaga, May 2, 2012 ?> <!--## if (TABLE.TblUseGlobal) { ##--> <?php if ( (MS_PAGINATION_POSITION==1) || (MS_PAGINATION_POSITION==3) ) { ?> <!--##=sExpStart##--> <div class="ewGridUpperPanel"> <?php if ($<!--##=gsTblVar##-->->CurrentAction <> "gridadd" && $<!--##=gsTblVar##-->->CurrentAction <> "gridedit") { ?> <!--##include pager.php/pager##--> <?php } ?> <!--##include list-script-inline.php/optionhtml##--> </div> <!--##=sExpEnd##--> <?php } ?> <!--## } else { ##--> <!--## if (bTopPageLink || (bTopPageLink && bBottomPageLink)) { ##--> <!--##=sExpStart##--> <div class="ewGridUpperPanel"> <?php if ($<!--##=gsTblVar##-->->CurrentAction <> "gridadd" && $<!--##=gsTblVar##-->->CurrentAction <> "gridedit") { ?> <!--##include pager.php/pager##--> <?php } ?> <!--##include list-script-inline.php/optionhtml##--> </div> <!--##=sExpEnd##--> <!--## } ##--> <!--## } ##--> <?php // End of modification Customize Navigation/Pager Panel, by Masino Sinaga, May 2, 2012 ?> -
Still in the \Script\view-script.php file, find again this code:
<!--## if (bDetailViewPaging && bBottomPageLink) { ##--> <!--##=sExpStart##--> <br /> <!--##include pager.php/pager##--> <!--##=sExpEnd##--> <!--## } ##-->then replace it with the following code:
<?php // Begin of modification Customize Navigation/Pager Panel, by Masino Sinaga, May 2, 2012 ?> <!--## if (TABLE.TblUseGlobal) { ##--> <?php if ( (MS_PAGINATION_POSITION==2) || (MS_PAGINATION_POSITION==3) ) { ?> <?php if ($<!--##=sPageObj##-->->TotalRecs > 0) { ?> <!--##=sExpStart##--> <div class="ewGridLowerPanel"> <?php if ($<!--##=gsTblVar##-->->CurrentAction <> "gridadd" && $<!--##=gsTblVar##-->->CurrentAction <> "gridedit") { ?> <!--##include pager.php/pager##--> <?php } ?> <!--##include list-script-inline.php/optionhtml##--> </div> <!--##=sExpEnd##--> <?php } ?> <?php } ?> <!--## } else { ##--> <!--## if (bBottomPageLink || (bTopPageLink && bBottomPageLink)) { ##--> <?php if ($<!--##=sPageObj##-->->TotalRecs > 0) { ?> <!--##=sExpStart##--> <div class="ewGridLowerPanel"> <?php if ($<!--##=gsTblVar##-->->CurrentAction <> "gridadd" && $<!--##=gsTblVar##-->->CurrentAction <> "gridedit") { ?> <!--##include pager.php/pager##--> <?php } ?> <!--##include list-script-inline.php/optionhtml##--> </div> <!--##=sExpEnd##--> <?php } ?> <!--## } ##--> <!--## } ##--> <?php // End of modification Customize Navigation/Pager Panel, by Masino Sinaga, May 2, 2012 ?> -
Open your \Script\list-script-function.php file, and find this code:
function SetUpDisplayRecs() { $sWrk = @$_GET[EW_TABLE_REC_PER_PAGE];then replace it with the following code:
function SetUpDisplayRecs() { // Begin of modification Customize Navigation/Pager Panel, by Masino Sinaga, May 2, 2012 global $Language; $sWrk = @$_GET[EW_TABLE_REC_PER_PAGE]; if ($sWrk > MS_TABLE_MAXIMUM_SELECTED_RECORDS) { $sWrk = MS_TABLE_MAXIMUM_SELECTED_RECORDS; $this->setFailureMessage(str_replace("%t", MS_TABLE_MAXIMUM_SELECTED_RECORDS, $Language->Phrase("MaximumRecordsPerPage"))); } // End of modification Customize Navigation/Pager Panel, by Masino Sinaga, May 2, 2012 -
Replace all of the code in your \Script\pager.php file with the following code (Warning: Please backup your file first before doing this step!):
<!--##session pager##--> <!--## sImageFolder = ew_FolderPath("_images"); sImageFolder = ew_RelFolder(sImageFolder); ##--> <form name="ewpagerform" id="ewpagerform" class="msPagination" action="<?php echo ew_CurrentPage() ?>"> <table border="0" cellspacing="0" cellpadding="0" class="ewPager"> <tr> <!--## if (CTRL.CtrlID.toLowerCase() == "list") { ##--> <?php if ($<!--##=sPageObj##-->->TotalRecs > 0) { ?> <td><table border="0" cellspacing="0" cellpadding="0"><tr><td><!--##@RecordsPerPage##--> </td><td> <input type="hidden" name="t" value="<!--##=gsTblVar##-->" /> <select name="<?php echo EW_TABLE_REC_PER_PAGE ?>" id="<?php echo EW_TABLE_REC_PER_PAGE ?>" onchange="this.form.submit();"> <!--## if (TABLE.TblUseGlobal) { ##--> <?php $sRecPerPageList = explode(',', MS_TABLE_SELECTABLE_REC_PER_PAGE_LIST); ?> <!--## } else { ##--> <?php $sRecPerPageList = explode(',', '<!--##=sRecPerPageList##-->'); ?> <!--## } ##--> <?php foreach ($sRecPerPageList as $a) { $thisDisplayRecs = $a; if ($thisDisplayRecs > 0 ) { $thisValue = $thisDisplayRecs; ?> <option value="<?php echo $thisDisplayRecs; ?>"<?php if ($<!--##=sPageObj##-->->DisplayRecs == $thisValue) { ?> selected="selected"<?php } ?> /><?php echo $thisDisplayRecs; ?></option> <?php } else { ?> <option value="ALL"<?php if ($<!--##=gsTblVar##-->->getRecordsPerPage() == -1) { ?> selected="selected"<?php } ?>><!--##@AllRecords##--></option> <?php } } ?> </select></td></tr></table> </td> <td> </td> <?php } ?> <!--## } ##--> <td nowrap> <!--## if (TABLE.TblUseGlobal) { ##--> <?php if (MS_PAGINATION_STYLE==1) { ?> <span class="phpmaker"> <?php if (!isset($<!--##=sPageObj##-->->Pager)) $<!--##=sPageObj##-->->Pager = new cNumericPager($<!--##=sPageObj##-->->StartRec, $<!--##=sPageObj##-->->DisplayRecs, $<!--##=sPageObj##-->->TotalRecs, $<!--##=sPageObj##-->->RecRange) ?> <?php if ($<!--##=sPageObj##-->->Pager->RecordCount > 0) { ?> <?php if (($<!--##=sPageObj##-->->Pager->PageCount==1) && ($<!--##=sPageObj##-->->Pager->CurrentPage == 1) && (MS_SHOW_PAGENUM_IF_REC_NOT_OVER_PAGESIZE==FALSE) ) { ?> <!--## if (CTRL.CtrlID.toLowerCase() == "view") { ##--> <span class="phpmaker"><!--##@Page##--> <?php echo $<!--##=sPageObj##-->->Pager->FromIndex ?> <!--##@To##--> <?php echo $<!--##=sPageObj##-->->Pager->ToIndex ?> <!--##@Of##--> <?php echo $<!--##=sPageObj##-->->Pager->RecordCount ?></span> <!--## } ##--> <?php } else { ?> <?php if ($<!--##=sPageObj##-->->Pager->FirstButton->Enabled) { ?> <a href="<?php echo $<!--##=sPageObj##-->->PageUrl() ?>start=<?php echo $<!--##=sPageObj##-->->Pager->FirstButton->Start ?>"><b><!--##@PagerFirst##--></b></a> <?php } ?> <?php if ($<!--##=sPageObj##-->->Pager->PrevButton->Enabled) { ?> <a href="<?php echo $<!--##=sPageObj##-->->PageUrl() ?>start=<?php echo $<!--##=sPageObj##-->->Pager->PrevButton->Start ?>"><b><!--##@PagerPrevious##--></b></a> <?php } ?> <?php foreach ($<!--##=sPageObj##-->->Pager->Items as $PagerItem) { ?> <?php if ($PagerItem->Enabled) { ?><a href="<?php echo $<!--##=sPageObj##-->->PageUrl() ?>start=<?php echo $PagerItem->Start ?>"><?php } ?><b><?php echo $PagerItem->Text ?></b><?php if ($PagerItem->Enabled) { ?></a><?php } ?> <?php } ?> <?php if ($<!--##=sPageObj##-->->Pager->NextButton->Enabled) { ?> <a href="<?php echo $<!--##=sPageObj##-->->PageUrl() ?>start=<?php echo $<!--##=sPageObj##-->->Pager->NextButton->Start ?>"><b><!--##@PagerNext##--></b></a> <?php } ?> <?php if ($<!--##=sPageObj##-->->Pager->LastButton->Enabled) { ?> <a href="<?php echo $<!--##=sPageObj##-->->PageUrl() ?>start=<?php echo $<!--##=sPageObj##-->->Pager->LastButton->Start ?>"><b><!--##@PagerLast##--></b></a> <?php } ?> <?php } ?> <!--## if (CTRL.CtrlID.toLowerCase() == "list") { ##--> <?php if ($<!--##=sPageObj##-->->Pager->ButtonCount > 0) { ?> <?php } ?> <!--##@Record##--> <?php echo $<!--##=sPageObj##-->->Pager->FromIndex ?> <!--##@To##--> <?php echo $<!--##=sPageObj##-->->Pager->ToIndex ?> <!--##@Of##--> <?php echo $<!--##=sPageObj##-->->Pager->RecordCount ?> <!--## } ##--> <?php } else { ?> <!--## if (bUserLevel && !bAnonymousList) { ##--> <?php if ($Security->CanList()) { ?> <!--## } ##--> <?php if ($<!--##=sPageObj##-->->SearchWhere == "0=101") { ?> <!--##@EnterSearchCriteria##--> <?php } else { ?> <!--##@NoRecord##--> <?php } ?> <!--## if (bUserLevel && !bAnonymousList) { ##--> <?php } else { ?> <!--##@NoPermission##--> <?php } ?> <!--## } ##--> <?php } ?> </span> <?php } elseif (MS_PAGINATION_STYLE==2) { ?> <?php if (!isset($<!--##=sPageObj##-->->Pager)) $<!--##=sPageObj##-->->Pager = new cPrevNextPager($<!--##=sPageObj##-->->StartRec, $<!--##=sPageObj##-->->DisplayRecs, $<!--##=sPageObj##-->->TotalRecs) ?> <?php if ($<!--##=sPageObj##-->->Pager->RecordCount > 0) { ?> <?php if (($<!--##=sPageObj##-->->Pager->PageCount==1) && ($<!--##=sPageObj##-->->Pager->CurrentPage == 1) && (MS_SHOW_PAGENUM_IF_REC_NOT_OVER_PAGESIZE==FALSE) ) { ?> <!--## if (CTRL.CtrlID.toLowerCase() == "view") { ##--> <span class="phpmaker"><!--##@Page##--> <?php echo $<!--##=sPageObj##-->->Pager->FromIndex ?> <!--##@To##--> <?php echo $<!--##=sPageObj##-->->Pager->ToIndex ?> <!--##@Of##--> <?php echo $<!--##=sPageObj##-->->Pager->RecordCount ?></span> <!--## } ##--> <?php } else { ?> <table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpmaker"><!--##@Page##--> </span></td> <!--first page button--> <?php if ($<!--##=sPageObj##-->->Pager->FirstButton->Enabled) { ?> <td><a href="<?php echo $<!--##=sPageObj##-->->PageUrl() ?>start=<?php echo $<!--##=sPageObj##-->->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 ($<!--##=sPageObj##-->->Pager->PrevButton->Enabled) { ?> <td><a href="<?php echo $<!--##=sPageObj##-->->PageUrl() ?>start=<?php echo $<!--##=sPageObj##-->->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="<?php echo EW_TABLE_PAGE_NO ?>" id="<?php echo EW_TABLE_PAGE_NO ?>" value="<?php echo $<!--##=sPageObj##-->->Pager->CurrentPage ?>" size="4"></td> <!--next page button--> <?php if ($<!--##=sPageObj##-->->Pager->NextButton->Enabled) { ?> <td><a href="<?php echo $<!--##=sPageObj##-->->PageUrl() ?>start=<?php echo $<!--##=sPageObj##-->->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 ($<!--##=sPageObj##-->->Pager->LastButton->Enabled) { ?> <td><a href="<?php echo $<!--##=sPageObj##-->->PageUrl() ?>start=<?php echo $<!--##=sPageObj##-->->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="phpmaker"> <!--##@of##--> <?php echo $<!--##=sPageObj##-->->Pager->PageCount ?></span></td> </tr></table> <?php } ?> <!--## if (CTRL.CtrlID.toLowerCase() == "list") { ##--> </td> <td> </td> <td> <span class="phpmaker"><!--##@Record##--> <?php echo $<!--##=sPageObj##-->->Pager->FromIndex ?> <!--##@To##--> <?php echo $<!--##=sPageObj##-->->Pager->ToIndex ?> <!--##@Of##--> <?php echo $<!--##=sPageObj##-->->Pager->RecordCount ?></span> <!--## } ##--> <?php } else { ?> <!--## if (bUserLevel && !bAnonymousList) { ##--> <?php if ($Security->CanList()) { ?> <!--## } ##--> <?php if ($<!--##=sPageObj##-->->SearchWhere == "0=101") { ?> <span class="phpmaker"><!--##@EnterSearchCriteria##--></span> <?php } else { ?> <span class="phpmaker"><!--##@NoRecord##--></span> <?php } ?> <!--## if (bUserLevel && !bAnonymousList) { ##--> <?php } else { ?> <span class="phpmaker"><!--##@NoPermission##--></span> <?php } ?> <!--## } ##--> <?php } ?> <?php } ?> <!--## } else { ##--> <!--## switch (iPagerStyle) { case 1: // Pager Style 1 ##--> <span class="phpmaker"> <?php if (!isset($<!--##=sPageObj##-->->Pager)) $<!--##=sPageObj##-->->Pager = new cNumericPager($<!--##=sPageObj##-->->StartRec, $<!--##=sPageObj##-->->DisplayRecs, $<!--##=sPageObj##-->->TotalRecs, $<!--##=sPageObj##-->->RecRange) ?> <?php if ($<!--##=sPageObj##-->->Pager->RecordCount > 0) { ?> <?php if (($<!--##=sPageObj##-->->Pager->PageCount==1) && ($<!--##=sPageObj##-->->Pager->CurrentPage == 1) && (MS_SHOW_PAGENUM_IF_REC_NOT_OVER_PAGESIZE==FALSE) ) { ?> <!--## if (CTRL.CtrlID.toLowerCase() == "view") { ##--> <span class="phpmaker"><!--##@Page##--> <?php echo $<!--##=sPageObj##-->->Pager->FromIndex ?> <!--##@To##--> <?php echo $<!--##=sPageObj##-->->Pager->ToIndex ?> <!--##@Of##--> <?php echo $<!--##=sPageObj##-->->Pager->RecordCount ?></span> <!--## } ##--> <?php } else { ?> <?php if ($<!--##=sPageObj##-->->Pager->FirstButton->Enabled) { ?> <a href="<?php echo $<!--##=sPageObj##-->->PageUrl() ?>start=<?php echo $<!--##=sPageObj##-->->Pager->FirstButton->Start ?>"><b><!--##@PagerFirst##--></b></a> <?php } ?> <?php if ($<!--##=sPageObj##-->->Pager->PrevButton->Enabled) { ?> <a href="<?php echo $<!--##=sPageObj##-->->PageUrl() ?>start=<?php echo $<!--##=sPageObj##-->->Pager->PrevButton->Start ?>"><b><!--##@PagerPrevious##--></b></a> <?php } ?> <?php foreach ($<!--##=sPageObj##-->->Pager->Items as $PagerItem) { ?> <?php if ($PagerItem->Enabled) { ?><a href="<?php echo $<!--##=sPageObj##-->->PageUrl() ?>start=<?php echo $PagerItem->Start ?>"><?php } ?><b><?php echo $PagerItem->Text ?></b><?php if ($PagerItem->Enabled) { ?></a><?php } ?> <?php } ?> <?php if ($<!--##=sPageObj##-->->Pager->NextButton->Enabled) { ?> <a href="<?php echo $<!--##=sPageObj##-->->PageUrl() ?>start=<?php echo $<!--##=sPageObj##-->->Pager->NextButton->Start ?>"><b><!--##@PagerNext##--></b></a> <?php } ?> <?php if ($<!--##=sPageObj##-->->Pager->LastButton->Enabled) { ?> <a href="<?php echo $<!--##=sPageObj##-->->PageUrl() ?>start=<?php echo $<!--##=sPageObj##-->->Pager->LastButton->Start ?>"><b><!--##@PagerLast##--></b></a> <?php } ?> <?php } ?> <!--## if (CTRL.CtrlID.toLowerCase() == "list") { ##--> <?php if ($<!--##=sPageObj##-->->Pager->ButtonCount > 0) { ?> <?php } ?> <!--##@Record##--> <?php echo $<!--##=sPageObj##-->->Pager->FromIndex ?> <!--##@To##--> <?php echo $<!--##=sPageObj##-->->Pager->ToIndex ?> <!--##@Of##--> <?php echo $<!--##=sPageObj##-->->Pager->RecordCount ?> <!--## } ##--> <?php } else { ?> <!--## if (bUserLevel && !bAnonymousList) { ##--> <?php if ($Security->CanList()) { ?> <!--## } ##--> <?php if ($<!--##=sPageObj##-->->SearchWhere == "0=101") { ?> <!--##@EnterSearchCriteria##--> <?php } else { ?> <!--##@NoRecord##--> <?php } ?> <!--## if (bUserLevel && !bAnonymousList) { ##--> <?php } else { ?> <!--##@NoPermission##--> <?php } ?> <!--## } ##--> <?php } ?> </span> <!--## break; case 2: // Pager Style 2 ##--> <?php if (!isset($<!--##=sPageObj##-->->Pager)) $<!--##=sPageObj##-->->Pager = new cPrevNextPager($<!--##=sPageObj##-->->StartRec, $<!--##=sPageObj##-->->DisplayRecs, $<!--##=sPageObj##-->->TotalRecs) ?> <?php if ($<!--##=sPageObj##-->->Pager->RecordCount > 0) { ?> <?php if (($<!--##=sPageObj##-->->Pager->PageCount==1) && ($<!--##=sPageObj##-->->Pager->CurrentPage == 1) && (MS_SHOW_PAGENUM_IF_REC_NOT_OVER_PAGESIZE==FALSE) ) { ?> <!--## if (CTRL.CtrlID.toLowerCase() == "view") { ##--> <span class="phpmaker"><!--##@Page##--> <?php echo $<!--##=sPageObj##-->->Pager->FromIndex ?> <!--##@To##--> <?php echo $<!--##=sPageObj##-->->Pager->ToIndex ?> <!--##@Of##--> <?php echo $<!--##=sPageObj##-->->Pager->RecordCount ?></span> <!--## } ##--> <?php } else { ?> <table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpmaker"><!--##@Page##--> </span></td> <!--first page button--> <?php if ($<!--##=sPageObj##-->->Pager->FirstButton->Enabled) { ?> <td><a href="<?php echo $<!--##=sPageObj##-->->PageUrl() ?>start=<?php echo $<!--##=sPageObj##-->->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 ($<!--##=sPageObj##-->->Pager->PrevButton->Enabled) { ?> <td><a href="<?php echo $<!--##=sPageObj##-->->PageUrl() ?>start=<?php echo $<!--##=sPageObj##-->->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="<?php echo EW_TABLE_PAGE_NO ?>" id="<?php echo EW_TABLE_PAGE_NO ?>" value="<?php echo $<!--##=sPageObj##-->->Pager->CurrentPage ?>" size="4"></td> <!--next page button--> <?php if ($<!--##=sPageObj##-->->Pager->NextButton->Enabled) { ?> <td><a href="<?php echo $<!--##=sPageObj##-->->PageUrl() ?>start=<?php echo $<!--##=sPageObj##-->->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 ($<!--##=sPageObj##-->->Pager->LastButton->Enabled) { ?> <td><a href="<?php echo $<!--##=sPageObj##-->->PageUrl() ?>start=<?php echo $<!--##=sPageObj##-->->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="phpmaker"> <!--##@of##--> <?php echo $<!--##=sPageObj##-->->Pager->PageCount ?></span></td> </tr></table> <?php } ?> <!--## if (CTRL.CtrlID.toLowerCase() == "list") { ##--> </td> <td> </td> <td> <span class="phpmaker"><!--##@Record##--> <?php echo $<!--##=sPageObj##-->->Pager->FromIndex ?> <!--##@To##--> <?php echo $<!--##=sPageObj##-->->Pager->ToIndex ?> <!--##@Of##--> <?php echo $<!--##=sPageObj##-->->Pager->RecordCount ?></span> <!--## } ##--> <?php } else { ?> <!--## if (bUserLevel && !bAnonymousList) { ##--> <?php if ($Security->CanList()) { ?> <!--## } ##--> <?php if ($<!--##=sPageObj##-->->SearchWhere == "0=101") { ?> <span class="phpmaker"><!--##@EnterSearchCriteria##--></span> <?php } else { ?> <span class="phpmaker"><!--##@NoRecord##--></span> <?php } ?> <!--## if (bUserLevel && !bAnonymousList) { ##--> <?php } else { ?> <span class="phpmaker"><!--##@NoPermission##--></span> <?php } ?> <!--## } ##--> <?php } ?> <!--## break; } ##--> <!--## } ##--> </td> <!--## if (ew_IsNotEmpty(sRecPerPageList) && CTRL.CtrlID.toLowerCase() == "list") { var arrRecPerPage = sRecPerPageList.split(","); ##--> <!--## } ##--> </tr> </table> </form> <!--##/session##--> <?php <!--##session pagerfunction##--> // Set up starting record parameters function SetUpStartRec() { if ($this->DisplayRecs == 0) return; if ($this->IsPageRequest()) { // Validate request if (@$_GET[EW_TABLE_START_REC] <> "") { // Check for "start" parameter $this->StartRec = $_GET[EW_TABLE_START_REC]; $this->setStartRecordNumber($this->StartRec); } elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") { $PageNo = $_GET[EW_TABLE_PAGE_NO]; if (is_numeric($PageNo)) { $this->StartRec = ($PageNo-1)*$this->DisplayRecs+1; if ($this->StartRec <= 0) { $this->StartRec = 1; } elseif ($this->StartRec >= intval(($this->TotalRecs-1)/$this->DisplayRecs)*$this->DisplayRecs+1) { $this->StartRec = intval(($this->TotalRecs-1)/$this->DisplayRecs)*$this->DisplayRecs+1; } $this->setStartRecordNumber($this->StartRec); } } } $this->StartRec = $this->getStartRecordNumber(); // Check if correct start record counter if (!is_numeric($this->StartRec) || $this->StartRec == "") { // Avoid invalid start record counter $this->StartRec = 1; // Reset start record counter $this->setStartRecordNumber($this->StartRec); } elseif (intval($this->StartRec) > intval($this->TotalRecs)) { // Avoid starting record > total records $this->StartRec = intval(($this->TotalRecs-1)/$this->DisplayRecs)*$this->DisplayRecs+1; // Point to last page first record $this->setStartRecordNumber($this->StartRec); } elseif (($this->StartRec-1) % $this->DisplayRecs <> 0) { $this->StartRec = intval(($this->StartRec-1)/$this->DisplayRecs)*$this->DisplayRecs+1; // Point to page boundary $this->setStartRecordNumber($this->StartRec); } } <!--##/session##--> ?> -
Next step, we will add our new style to the .css file that will be generated by PHPMaker. This will beautify your pagination section by adding colored background and outlined around its panel. From your PHPMaker application, go to HTML tab, then click on Styles sub-tab, and then click on Edit Styles button. You will see a CSS Editor window afterwards. Scroll down to the bottom of that textbox, and find this code:
/*END_USER_STYLES*/
before that line, please insert the following code:
/* Begin of modification Customize Navigation/Pager Panel, by Masino Sinaga, May 2, 2012 */ .msPagination { background-color: #EEEEEE; border-left: 1px solid #CACACA; border-right: 1px solid #CACACA; border-top: 1px solid #CACACA; border-bottom: 1px solid #CACACA; padding: 0.5em; text-align: left; font-family: tahoma; /* font name */ display: block; vertical-align:top; } /* End of modification Customize Navigation/Pager Panel, by Masino Sinaga, May 2, 2012 */afterwards click on OK button to save the changes and close the CSS Editor window.
-
Open your \Script\phpfn.php file, and find this code:
/** * Numeric pager class */ class cNumericPager { var $Items = array(); var $Count, $FromIndex, $ToIndex, $RecordCount, $PageSize, $Range; var $FirstButton, $PrevButton, $NextButton, $LastButton; var $ButtonCount = 0; var $Visible = TRUE; function __construct($StartRec, $DisplayRecs, $TotalRecs, $RecRange) { $this->FirstButton = new cPagerItem; $this->PrevButton = new cPagerItem; $this->NextButton = new cPagerItem; $this->LastButton = new cPagerItem; $this->FromIndex = intval($StartRec); $this->PageSize = intval($DisplayRecs); $this->RecordCount = intval($TotalRecs); $this->Range = intval($RecRange); if ($this->PageSize == 0) return; if ($this->FromIndex > $this->RecordCount) $this->FromIndex = $this->RecordCount; $this->ToIndex = $this->FromIndex + $this->PageSize - 1; if ($this->ToIndex > $this->RecordCount) $this->ToIndex = $this->RecordCount;then replace it with the following code:
/** * Numeric pager class */ class cNumericPager { var $Items = array(); var $Count, $FromIndex, $ToIndex, $RecordCount, $PageSize, $Range; var $FirstButton, $PrevButton, $NextButton, $LastButton, $CurrentPage; var $ButtonCount = 0; var $Visible = TRUE; function __construct($StartRec, $DisplayRecs, $TotalRecs, $RecRange) { $this->FirstButton = new cPagerItem; $this->PrevButton = new cPagerItem; $this->NextButton = new cPagerItem; $this->LastButton = new cPagerItem; $this->FromIndex = intval($StartRec); $this->PageSize = intval($DisplayRecs); $this->RecordCount = intval($TotalRecs); $this->Range = intval($RecRange); if ($this->PageSize == 0) return; $this->CurrentPage = intval(($this->FromIndex-1)/$this->PageSize) + 1; $this->PageCount = intval(($this->RecordCount-1)/$this->PageSize) + 1; if ($this->FromIndex > $this->RecordCount) $this->FromIndex = $this->RecordCount; $this->ToIndex = $this->FromIndex + $this->PageSize - 1; if ($this->ToIndex > $this->RecordCount) $this->ToIndex = $this->RecordCount; // First Button $TempIndex = 1; $this->FirstButton->Start = $TempIndex; $this->FirstButton->Enabled = ($TempIndex <> $this->FromIndex); // Prev Button $TempIndex = $this->FromIndex - $this->PageSize; if ($TempIndex < 1) $TempIndex = 1; $this->PrevButton->Start = $TempIndex; $this->PrevButton->Enabled = ($TempIndex <> $this->FromIndex); // Next Button $TempIndex = $this->FromIndex + $this->PageSize; if ($TempIndex > $this->RecordCount) $TempIndex = $this->FromIndex; $this->NextButton->Start = $TempIndex; $this->NextButton->Enabled = ($TempIndex <> $this->FromIndex); // Last Button $TempIndex = intval(($this->RecordCount-1)/$this->PageSize)*$this->PageSize + 1; $this->LastButton->Start = $TempIndex; $this->LastButton->Enabled = ($TempIndex <> $this->FromIndex); - Finally, re-generate your script files as usual using PHPMaker.
[/hidepost]
Does this work with 9.0.2?
Yes. It works fine with PHPMaker 9.0.2.
Masino,
I’ve tried this twice in 9.0.2 and could not get it to work. I was very careful the 2nd time and performed the copy/paste exactly.
however, I continue to get a parse error:
Parse error: syntax error, unexpected $end in C:\xampp\htdocs\weekendsupport.org\weekends_list.php on line 4051
If I undo the changes, it returns to normal.
I have re-checked and compared between the original template and the customization template, and the customized one matches with my customized template. It also works fine in mine. Please re-check again the step 4, 5, 6, and 7 above, since there is the similar code in some places. Also, be careful in step 5 since you have to copy the replacement code in the scrolled text area above.
Today I tested the customization above in PHPMaker Template for v9.0.4 and it worked fine. Just wanted to make sure that it is working fine for the latest version, too.