Another great feature in PHPMaker is the ability to define which records will be exported to the certain media/files. There are three options available that you can choose from PHP tab -> List/View Page Options (Global) sub-tab -> Export groupbox -> Export Type selection. The first option is All pages which means that records in all pages are exported. The second option is Current page which means that all records in current page are exported. And the last/third option is Selected records which means a checkbox will be displayed in each row for selection. Only selected records in the current page are exported (selecting records in different pages is not allowed). To select records primary key is required, Current Page export type will be used for tables without primary key.
Unfortunately, PHPMaker only allows you to choose one of the three options above. If --- for example --- someday you want to switch from the current option to another, then you have to change it from your PHPMaker project application, afterwards you have to re-generate all the related pages that contain this export feature. Imagine now if you have to re-generate the hundred pages and then you have to re-upload them again to your web server. I think there should be another efficient and effective way to overcome this issue, right?
Well, I have successfully customized the PHPMaker template in order to make it come true. Besides that, there is a new constant I added into the configuration (ewcfg*.php) file. Now you only need to change this constant value and save the change, afterwards, your users will use the new settings in all pages that contain the export feature. In other words, you don't have to re-generate your .php files anymore each time you want to change from the old option to the new option of the three options above.
Yes. Again, your life becomes easier. 🙂
[hidepost]
-
Open your /Script/ewcfg.php file, and find this code:
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 mofidication Flexibility of Export Records Options, added by Masino Sinaga, February 27, 2012 define("EW_EXPORT_RECORD_OPTIONS", "allpages", TRUE); // available values: "allpages", "currentpage", "selectedrecords" // End of modification Flexibility of Export Records Options, added by Masino Sinaga, February 27, 2012
-
Open your /Script/info.php file, and find this code:
var $ExportAll = <!--##=ew_Val(bExportAll)##-->;
then replace it with the following code:
var $ExportAll = EW_EXPORT_RECORD_OPTIONS; // <!--##=ew_Val(bExportAll)##-->; // Modified by Masino Sinaga, Flexibility of Export Records Options, February 27, 2012
-
Open your /Script/list-script.php file, and find this code:
<!--## If bExportSelectedOnly Then ##--> // Export selected records if ($<!--##=gsTblVar##-->->Export <> "") $<!--##=gsTblVar##-->->CurrentFilter = $this->BuildExportSelectedFilter(); <!--## End If ##-->
then replace it with the following code:
// Begin of mofidication Flexibility of Export Records Options, added by Masino Sinaga, February 27, 2012 if (EW_EXPORT_RECORD_OPTIONS=="selectedrecords") { // Export selected records if ($<!--##=gsTblVar##-->->Export <> "") $<!--##=gsTblVar##-->->CurrentFilter = $this->BuildExportSelectedFilter(); } // End of mofidication Flexibility of Export Records Options, added by Masino Sinaga, February 27, 2012
-
Still in the /Script/list-script.php file, find again this code:
<!--## If bExportSelectedOnly Then ##--> <input type="hidden" name="exporttype" id="exporttype" value="" /> <!--## End If ##-->
then replace it with the following code:
<?php // Begin of mofidication Flexibility of Export Record Options, added by Masino Sinaga, February 27, 2012 ?> <?php if (EW_EXPORT_RECORD_OPTIONS=="selectedrecords") { ?> <input type="hidden" name="exporttype" id="exporttype" value="" /> <?php } ?> <?php // End of mofidication Flexibility of Export Record Options, added by Masino Sinaga, February 27, 2012 ?>
-
Still in the /Script/list-script.php file, find again this code:
if ($<!--##=sPageObj##-->->DisplayRecs <= 0 || ($<!--##=gsTblVar##-->->Export <> "" && $<!--##=gsTblVar##-->->ExportAll)) // Display all records $<!--##=sPageObj##-->->DisplayRecs = $<!--##=sPageObj##-->->TotalRecs; if (!($<!--##=gsTblVar##-->->Export <> "" && $<!--##=gsTblVar##-->->ExportAll)) $<!--##=sPageObj##-->->SetUpStartRec(); // Set up start record position
then replace it with the following code:
if ($<!--##=sPageObj##-->->DisplayRecs <= 0 || ($<!--##=gsTblVar##-->->Export <> "" && $<!--##=gsTblVar##-->->ExportAll=="allpages")) // Display all records // Modified by Masino Sinaga, for the Flexibility Options for Export Records, February 27, 2012 $<!--##=sPageObj##-->->DisplayRecs = $<!--##=sPageObj##-->->TotalRecs; if (!($<!--##=gsTblVar##-->->Export <> "" && $<!--##=gsTblVar##-->->ExportAll=="allpages")) // Modified by Masino Sinaga, for the Flexibility Options for Export Records, February 27, 2012 $<!--##=sPageObj##-->->SetUpStartRec(); // Set up start record position
-
Still in the /Script/list-script.php file, find again this code:
if ($<!--##=gsTblVar##-->->ExportAll && $<!--##=gsTblVar##-->->Export <> "") { $<!--##=sPageObj##-->->StopRec = $<!--##=sPageObj##-->->TotalRecs;
then replace it with the following code:
if ($<!--##=gsTblVar##-->->ExportAll=="allpages" && $<!--##=gsTblVar##-->->Export <> "") { // Modified by Masino Sinaga, export flexibility options February 27, 2012 $<!--##=sPageObj##-->->StopRec = $<!--##=sPageObj##-->->TotalRecs;
-
Open your /Script/share-script.php file, and find this code:
<!--## If bExportSelectedOnly And CTRL.CtrlID = "list" Then ##--> // Build export filter for selected records function BuildExportSelectedFilter() { global $Language, $<!--##=gsTblVar##-->; $sWrkFilter = ""; if ($<!--##=gsTblVar##-->->Export <> "") { $sWrkFilter = $<!--##=gsTblVar##-->->GetKeyFilter(); } return $sWrkFilter; } <!--## End If ##-->
then replace it with the following code:
// Begin of mofidication Flexibility of Export Record Options, added by Masino Sinaga, February 27, 2012 // Build export filter for selected records function BuildExportSelectedFilter() { global $Language, $<!--##=gsTblVar##-->; $sWrkFilter = ""; if ($<!--##=gsTblVar##-->->Export <> "") { $sWrkFilter = $<!--##=gsTblVar##-->->GetKeyFilter(); } return $sWrkFilter; } // End of mofidication Flexibility of Export Record Options, added by Masino Sinaga, February 27, 2012
-
Still in the /Script/share-script.php file, find again this code:
function SetupExportOptions() { global $Language, $Security, $<!--##=gsTblVar##-->;
after the last line of that code, please insert the following code:
<!--## ' Config Form sFormName = "f" & TABLE.TblVar & CTRL.CtrlID ' Form Name sJsFormName = "document." & sFormName ##-->
-
Still in the /Script/share-script.php file, find again this code:
$item->Body = <!--##=sExportPrintUrl##--> . <!--##=sPrinterFriendlyCaption##--> . "</a>";
then replace it with the following code:
// Begin of modified by Masino Sinaga, export flexibility options February 27, 2012 if (EW_EXPORT_RECORD_OPTIONS=="selectedrecords") { $item->Body = "<a href=\"javascript:void(0);\" onclick=\"var f=document.<!--##=sFormName##-->;ew_SubmitSelectedExport(f,'" . ew_CurrentPage() . "','print');\">" . "<img src=\"phpimages/print.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("PrinterFriendly")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("PrinterFriendly")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>"; } else { $item->Body = "<a href=\"" . $this->ExportPrintUrl . "\">" . "<img src=\"phpimages/print.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("PrinterFriendly")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("PrinterFriendly")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>"; } // End of modified by Masino Sinaga, export flexibility options February 27, 2012
-
Still in the /Script/share-script.php file, find again this code:
$item->Body = <!--##=sExportExcelUrl##--> . <!--##=sExportToExcelCaption##--> . "</a>";
then replace it with the following code:
// Begin of modified by Masino Sinaga, export flexibility options February 27, 2012 if (EW_EXPORT_RECORD_OPTIONS=="selectedrecords") { $item->Body = "<a href=\"javascript:void(0);\" onclick=\"var f=document.<!--##=sFormName##-->;ew_SubmitSelectedExport(f,'" . ew_CurrentPage() . "','excel');\">" . "<img src=\"phpimages/exportxls.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("ExportToExcel")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("ExportToExcel")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>"; } else { $item->Body = "<a href=\"" . $this->ExportExcelUrl . "\">" . "<img src=\"phpimages/exportxls.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("ExportToExcel")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("ExportToExcel")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>"; } // End of modified by Masino Sinaga, export flexibility options February 27, 2012
-
Still in the /Script/share-script.php file, find again this code:
$item->Body = <!--##=sExportWordUrl##--> . <!--##=sExportToWordCaption##--> . "</a>";
then replace it with the following code:
// Begin of modified by Masino Sinaga, export flexibility options February 27, 2012 if (EW_EXPORT_RECORD_OPTIONS=="selectedrecords") { $item->Body = "<a href=\"javascript:void(0);\" onclick=\"var f=document.<!--##=sFormName##-->;ew_SubmitSelectedExport(f,'" . ew_CurrentPage() . "','word');\">" . "<img src=\"phpimages/exportdoc.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("ExportToWord")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("ExportToWord")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>"; } else { $item->Body = "<a href=\"" . $this->ExportWordUrl . "\">" . "<img src=\"phpimages/exportdoc.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("ExportToWord")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("ExportToWord")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>"; } // End of modified by Masino Sinaga, export flexibility options February 27, 2012
-
Still in the /Script/share-script.php file, find again this code:
$item->Body = <!--##=sExportHtmlUrl##--> . <!--##=sExportToHtmlCaption##--> . "</a>";
then replace it with the following code:
// Begin of modified by Masino Sinaga, export flexibility options February 27, 2012 if (EW_EXPORT_RECORD_OPTIONS=="selectedrecords") { $item->Body = "<a href=\"javascript:void(0);\" onclick=\"var f=document.<!--##=sFormName##-->;ew_SubmitSelectedExport(f,'" . ew_CurrentPage() . "','html');\">" . "<img src=\"phpimages/exporthtml.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("ExportToHtml")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("ExportToHtml")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>"; } else { $item->Body = "<a href=\"" . $this->ExportHtmlUrl . "\">" . "<img src=\"phpimages/exporthtml.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("ExportToHtml")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("ExportToHtml")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>"; } // End of modified by Masino Sinaga, export flexibility options February 27, 2012
-
Still in the /Script/share-script.php file, find again this code:
$item->Body = <!--##=sExportXmlUrl##--> . <!--##=sExportToXmlCaption##--> . "</a>";
then replace it with the following code:
// Begin of modified by Masino Sinaga, export flexibility options February 27, 2012 if (EW_EXPORT_RECORD_OPTIONS=="selectedrecords") { $item->Body = "<a href=\"javascript:void(0);\" onclick=\"var f=document.<!--##=sFormName##-->;ew_SubmitSelectedExport(f,'" . ew_CurrentPage() . "','xml');\">" . "<img src=\"phpimages/exportxml.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("ExportToXml")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("ExportToXml")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>"; } else { $item->Body = "<a href=\"" . $this->ExportXmlUrl . "\">" . "<img src=\"phpimages/exportxml.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("ExportToXml")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("ExportToXml")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>"; } // End of modified by Masino Sinaga, export flexibility options February 27, 2012
-
Still in the /Script/share-script.php file, find again this code:
$item->Body = <!--##=sExportCsvUrl##--> . <!--##=sExportToCsvCaption##--> . "</a>";
then replace it with the following code:
// Begin of modified by Masino Sinaga, export flexibility options February 27, 2012 if (EW_EXPORT_RECORD_OPTIONS=="selectedrecords") { $item->Body = "<a href=\"javascript:void(0);\" onclick=\"var f=document.<!--##=sFormName##-->;ew_SubmitSelectedExport(f,'" . ew_CurrentPage() . "','csv');\">" . "<img src=\"phpimages/exportcsv.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("ExportToCsv")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("ExportToCsv")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>"; } else { $item->Body = "<a href=\"" . $this->ExportCsvUrl . "\">" . "<img src=\"phpimages/exportcsv.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("ExportToCsv")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("ExportToCsv")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>"; } // End of modified by Masino Sinaga, export flexibility options February 27, 2012
-
Still in the /Script/share-script.php file, find again this code:
$item->Body = <!--##=sExportPdfUrl##--> . <!--##=sExportToPdfCaption##--> . "</a>";
then replace it with the following code:
// Begin of modified by Masino Sinaga, export flexibility options February 27, 2012 if (EW_EXPORT_RECORD_OPTIONS=="selectedrecords") { $item->Body = "<a href=\"javascript:void(0);\" onclick=\"var f=document.<!--##=sFormName##-->;ew_SubmitSelectedExport(f,'" . ew_CurrentPage() . "','pdf');\">" . "<img src=\"phpimages/exportpdf.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("ExportToPdf")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("ExportToPdf")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>"; } else { $item->Body = "<a href=\"" . $this->ExportPdfUrl . "\">" . "<img src=\"phpimages/exportpdf.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("ExportToPdf")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("ExportToPdf")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>"; } // End of modified by Masino Sinaga, export flexibility options February 27, 2012
-
Still in the /Script/share-script.php file, find again this code:
$item->Body = "<a name=\"emf_<!--##=gsTblVar##-->\" id=\"emf_<!--##=gsTblVar##-->\" href=\"javascript:void(0);\" onclick=\"ew_EmailDialogShow({lnk:'emf_<!--##=gsTblVar##-->',hdr:ewLanguage.Phrase('ExportToEmail'),f:<!--##=sJsFormName##-->,sel:<!--##=ew_JsVal(bExportSelectedOnly)##-->});\">" . <!--##=sExportToEmailCaption##--> . "</a>";
then replace it with the following code:
// Begin of modified by Masino Sinaga, export flexibility options February 27, 2012 if (EW_EXPORT_RECORD_OPTIONS=="selectedrecords") { $item->Body = "<a name=\"emf_masterkantor\" id=\"emf_masterkantor\" href=\"javascript:void(0);\" onclick=\"ew_EmailDialogShow({lnk:'emf_masterkantor',hdr:ewLanguage.Phrase('ExportToEmail'),f:document.<!--##=sFormName##-->,sel:true});\">" . "<img src=\"phpimages/exportemail.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("ExportToEmail")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("ExportToEmail")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>"; } else { $item->Body = "<a name=\"emf_masterkantor\" id=\"emf_masterkantor\" href=\"javascript:void(0);\" onclick=\"ew_EmailDialogShow({lnk:'emf_masterkantor',hdr:ewLanguage.Phrase('ExportToEmail'),f:document.<!--##=sFormName##-->,sel:false});\">" . "<img src=\"phpimages/exportemail.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("ExportToEmail")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("ExportToEmail")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>"; } // End of modified by Masino Sinaga, export flexibility options February 27, 2012
-
Still in that \Script\share-script.php file, find again this code:
// Export all if ($<!--##=gsTblVar##-->->ExportAll) {
then replace it with the following code:
// Export all if ($<!--##=gsTblVar##-->->ExportAll=="allpages") { // Modified by Masino Sinaga, export flexibility options February 27, 2012
- Open your .pmp (PHPMaker project) file using PHPMaker application. Go to PHP tab, click on the List/View Page Options (Global) sub-tab, and then make sure from the Export groupbox -> Export Type selection, you have selected Selected records option. Save the changes.
- Finally, re-generate all of the related script files as usual using PHPMaker.
[/hidepost]
Salem says
To move the “select checkbox” column to the left :
listoptions_load event:
$this->ListOptions->Items[“checkbox”]->OnLeft = TRUE;
Masino Sinaga says
No need to move the checkbox to the left since it was on the left already (by default).