PHPMaker generates the list page of your website without adding the record number column on the table that located in the list page. Meanwhile, there are so many requests that asking about how to add this record number column in the list page. Even this feature is not too important, sometimes we need this Record Number column to provide the better information for users about which record numbers are being displayed in the list for the current active page.
Well, this following customization will fulfil that request, indeed! I have successfully added the record number column on the list page in websites that created with PHPMaker 8.0.3. I also added a constant into the configuration file (ewcfg*.php) file in order to enable or disable this column on the list page. After implementing this customization, then you will see there will be a new column that sits on the very left of your list page. Please note that this customization is related to the table level, so we will use and optimize the List Page section that located in the Server Events -> Table-Specific of your table from the PHPMaker application. In other words, we do not customize any generated script files.
Please click on the following image to watch the demo:
[hidepost]
-
Open your /Scritp/ewcfg.php file, and find this code:
// Show SQL for debug define("EW_DEBUG_ENABLED", <!--##=ew_Val(PROJ.GetV("Debug"))##-->, TRUE); // TRUE to debug if (EW_DEBUG_ENABLED) error_reporting(-1); // Report all PHP errors
after the last line of that code, please insert the following code:
// Begin of modification Adding Record Number Column on List Page, added by Masino Sinaga, March 12, 2012 define("SHOW_RECORD_NUMBER_COLUMN_ON_LIST", TRUE, TRUE); // End of modification Adding Record Number Column on List Page, added by Masino Sinaga, March 12, 2012
- Open your PHPMaker project file (.pmp) using your PHPMaker application.
- Click on one of the tables/views in your project until you see there are two new tabs appearing in the right side of PHPMaker application. They are: Fields and Server Events/Client Scripts tabs. Click on the Server Events/Client Scripts tab. Please note that in this example, assuming that we are using the cars list that you can find in the demo script of PHPMaker. So you will see in the following code below, the variable regarding the list is $cars_list. Please adjust it with yours according to your table/view you choose.
-
Go to the Server Events -> Table-Specific -> List Page -> ListOptions_Load, and then replace all code in the ListOptions_Load function with this following code (assuming: you have not ever modified the original function, otherwise, adjust the following code to your existing code):
// ListOptions Load event function ListOptions_Load() { // Adding record number column, modified by Masino Sinaga, October 26, 2011 if (SHOW_RECORD_NUMBER_COLUMN_ON_LIST) { $opt =& $this->ListOptions->Add("RecNo"); // RecNo will refer to ListOptions_Rendered $opt->Header = "Record Number"; // the caption of column header $opt->CssStyle = "text-align: center;"; // make the content center align $opt->OnLeft = TRUE; // Link on left $opt->MoveTo(0); // Move to first column } // Adding record number column, modified by Masino Sinaga, October 26, 2011 }
-
Go to the Server Events -> Table-Specific -> List Page -> ListOptions_Rendered, and then replace all code in the ListOptions_Rendered function with this following code (assuming: you have not ever modified the original function, otherwise, adjust the following code to your existing code):
// ListOptions Rendered event function ListOptions_Rendered() { // Adding record number column, modified by Masino Sinaga, October 26, 2011 if (SHOW_RECORD_NUMBER_COLUMN_ON_LIST) { global $cars_list; // <-- Don't forget to change this variable, adjust it with your table variable, including the others below! // $this->ListOptions->Items["RecNo"]->Body = $cars_list->Pager->CurrentPage. " - ". $cars_list->DisplayRecs. " - ". $cars_list->StartRec; // $no = $x + ($PageNo-1)*$PageSize; if ($cars_list->Pager->CurrentPage > 1) { $no = $cars_list->RowCnt + ($cars_list->Pager->CurrentPage-1)*$cars_list->DisplayRecs; // normal list view, could be more than 1 page! } else { $no = $cars_list->RowCnt; // export to print list view, only 1 page! } $this->ListOptions->Items["RecNo"]->Body = $no; } // Adding record number column, modified by Masino Sinaga, October 26, 2011 }
- Re-generate your script files using PHPMaker application as usual, and enjoy the results.
[/hidepost]
[…] By Masino Sinaga Leave a Comment Still remember about the modification I made and wrote it in How to Add Record Number Column on The List Page in Websites Created With PHPMaker 8.0.3 article? Well, that modification only for adding the record number column on the list page, and not […]