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 for the exported list page (either using Printer Friendly, Export to Excel, Export to Word, Export to HTML, Export to XML, Export to CSV, or Export to PDF).
You will find that record number column will never show up in the exported list. This could be happened since PHPMaker handles the export data differs with adding a new column in the list page. So this following modification below will add the record number column in the exported list pages. This record number column will sit on the very left of your exported list. You may hide or show this record number column anytime you want, by simply adjusting the related constant in your ewcfg8.php (configuration) file. Does it sound cool, huh?
Curious? 😀
[hidepost]
Before we get started, important to know that I am using demo8 PHPMaker project. You will find in some part of the modifications, you need to change or replace the default variable name, such as $table_list with the real table name of yours. For example, if you have a table named offices, then you have to change it become: $offices_list. Please don't forget to adjust them with yours, okay?
-
Open your ewcfg.php template 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 errorsafter the last line of that code, please insert this following code:
// Begin of modification by Masino Sinaga, October 26, 2011 define("EW_SHOW_RECNUM_COLUMN_ON_EXPORTED_LIST", TRUE, TRUE); // whether to show record number column on the exported list // End of modification by Masino Sinaga, October 26, 2011 -
Open your phpfn.php template file, and find this code:
// Table Footer function ExportTableFooter() {before the first line of that code, please insert this following code:
// Begin of adding a new column as the plain text, modified by Masino Sinaga, October 26, 2011 function ExportText($txt) { switch ($this->Table->Export) { case "html": case "email": case "word": case "excel": case "pdf": $this->Text .= "<td>" . $txt . "</td>"; break; case "csv": if ($this->Line <> "") $this->Line .= ","; $this->Line .= "\"" . str_replace("\"", "\"\"", strval($txt)) . "\""; break; } } // End of adding a new column as the plain text, modified by Masino Sinaga, October 26, 2011 -
Open your ewshared.php template file, and find this code:
function XML() {before that line, please insert this following code:
// Begin of adding a new column as the plain text, modified by Masino Sinaga, October 26, 2011 function AddXMLText($name, $value) { if (is_null($value)) $value = $this->NullValue; $value = ew_ConvertToUtf8($value); // Convert to UTF-8 $xmlfld = $this->XmlDoc->createElement(ew_XmlTagName($name)); $this->XmlRow->appendChild($xmlfld); $xmlfld->appendChild($this->XmlDoc->createTextNode($value)); } // End of adding a new column as the plain text, modified by Masino Sinaga, October 26, 2011 -
Open your list-script-function.php file, and find this code:
<!--##session renderlistoptionsext-start##--> function RenderListOptionsExt() { global $Security, $Language, $<!--##=gsTblVar##-->; <!--##/session##--> <!--##session renderlistoptionsext-end##-->then replace it with this following code:
<!--##session renderlistoptionsext-start##--> function RenderListOptionsExt() { global $Security, $Language, $<!--##=gsTblVar##-->; // Adding record number column, modified by Masino Sinaga, October 26, 2011 if (EW_SHOW_RECNUM_COLUMN_ON_EXPORTED_LIST) { global $<!--##=gsTblVar##-->_list; $opt = $this->ListOptions->Add("RecNo"); $opt->Header = "Record Number"; $opt->OnLeft = TRUE; // Link on left $opt->MoveTo(0); // Move to first column } // Adding record number column, modified by Masino Sinaga, October 26, 2011 <!--##/session##--> <!--##session renderlistoptionsext-end##-->This is important in order to show the record number column properly in the exported list in the Printer Friendly page.
-
Open your C:\Program Files\PHPMaker 8\src\phpcodebase.xml file, and find this code:
function ListOptions_Load() { // Example: //$opt =& $this->ListOptions->Add("new"); //$opt->Header = "xxx"; //$opt->OnLeft = TRUE; // Link on left //$opt->MoveTo(0); // Move to first column }then replace it with this following code:
function ListOptions_Load() { // Example: //$opt =& $this->ListOptions->Add("new"); //$opt->Header = "xxx"; //$opt->OnLeft = TRUE; // Link on left //$opt->MoveTo(0); // Move to first column if (EW_SHOW_RECNUM_COLUMN_ON_EXPORTED_LIST) { $opt =& $this->ListOptions->Add("RecNo"); $opt->Header = "Record Number"; $opt->OnLeft = TRUE; // Link on left $opt->MoveTo(0); // Move to first column } } -
Still in the C:\Program Files\PHPMaker 8\src\phpcodebase.xml file, find again this code:
function ListOptions_Rendered() { // Example: //$this->ListOptions->Items["new"]->Body = "xxx"; }then replace it with this following code:
function ListOptions_Rendered() { // Example: //$this->ListOptions->Items["new"]->Body = "xxx"; if (EW_SHOW_RECNUM_COLUMN_ON_EXPORTED_LIST) { // Please change $table_list with your real variable table name. // For example, this selected table is users, then replace $table_list with $users_list global $table_list; // $this->ListOptions->Items["RecNo"]->Body = $table_list->Pager->CurrentPage. " - ". $table_list->DisplayRecs. " - ". $table_list->StartRec; // $no = $x + ($PageNo-1)*$PageSize; if ($table_list->Pager->CurrentPage > 1) { $no = $table_list->RowCnt + ($table_list->Pager->CurrentPage-1)*$table_list->DisplayRecs; // normal list view, could be more than 1 page } else { $no = $table_list->RowCnt; // export to print list view, only 1 page } $this->ListOptions->Items["RecNo"]->Body = $no; } }Please note, that you have to change or replace the $table_list variable with the real variable table of yours, since it is located inside the Server Events in your PHPMaker application, then you have to change that $table_list with the real variable table manually. So, please be kind!
-
Open your info.php template file, and find this code:
$XmlDoc->AddRow(); if ($ExportPageType == "view") {after the last line of that code, please insert this following code:
// Begin of Show record number column on the exported list, by Masino Sinaga, October 26, 2011 if (EW_SHOW_RECNUM_COLUMN_ON_EXPORTED_LIST) { $XmlDoc->AddXMLText('Rec', $RecCnt); } // End of Show record number column on the exported list, by Masino Sinaga, October 26, 2011 -
Still in info.php template file, find again this code:
$XmlDoc->AddField('<!--##=gsFldParm##-->', $<!--##=gsFldObj##-->->ExportValue($this->Export, $this->ExportOriginalValue)); <!--## End If End If Next ##--> } else {after the last line of that code, please insert this following code:
// Begin of Show record number column on the exported list, by Masino Sinaga, October 26, 2011 if (EW_SHOW_RECNUM_COLUMN_ON_EXPORTED_LIST) { $XmlDoc->AddXMLText('Rec', $RecCnt); } // End of Show record number column on the exported list, by Masino Sinaga, October 26, 2011 -
Still in info.php template file, find again this code (inside the ExportDocument function):
$Doc->BeginExportRow(); if ($ExportPageType == "view") {after the last line of that code, please insert this following code:
// Begin of Show record number column on the exported list, by Masino Sinaga, October 26, 2011 if (EW_SHOW_RECNUM_COLUMN_ON_EXPORTED_LIST) { $Doc->ExportText("Rec#"); } // End of Show record number column on the exported list, by Masino Sinaga, October 26, 2011 -
Still in info.php template file, find again this code (inside the ExportDocument function):
$Doc->ExportCaption($<!--##=gsFldObj##-->); <!--## End If End If Next ##--> } else {after the last line of that code, please insert this following code:
// Begin of Show record number column on the exported list, by Masino Sinaga, October 26, 2011 if (EW_SHOW_RECNUM_COLUMN_ON_EXPORTED_LIST) { $Doc->ExportText("Rec#"); } // End of Show record number column on the exported list, by Masino Sinaga, October 26, 2011 -
Still in info.php template file, find again this code (inside the ExportDocument function):
$Doc->BeginExportRow($RowCnt); // Allow CSS styles if enabled if ($ExportPageType == "view") {after the last line of that code, please insert this following code:
// Begin of Show record number column on the exported list, by Masino Sinaga, October 26, 2011 if (EW_SHOW_RECNUM_COLUMN_ON_EXPORTED_LIST) { $Doc->ExportText($RecCnt); } // End of Show record number column on the exported list, by Masino Sinaga, October 26, 2011 -
Still in info.php template file, find again this code (inside the ExportDocument function):
$Doc->ExportField($<!--##=gsFldObj##-->); <!--## End If End If Next ##--> } else {after the last line of that code, please insert this following code:
// Begin of Show record number column on the exported list, by Masino Sinaga, October 26, 2011 if (EW_SHOW_RECNUM_COLUMN_ON_EXPORTED_LIST) { $Doc->ExportText($RecCnt); } // End of Show record number column on the exported list, by Masino Sinaga, October 26, 2011
[/hidepost]
Leave a Reply
You must be logged in to post a comment.