PreviewRow extension (only for the registered PHPMaker users) is one of the best extensions that provided by PHPMaker. It will turn your List pages which have some detail pages in it into several tabs. The tabs are hidden by default, and replaced by only plus (+) icon. When you click on the icon, then the detail pages that represented by tabs will be shown. This is very good if you have more than one detail pages. In addition it will save the space in your web application, it also makes the look and view of your web application becomes more professional.
Unfortunately, up to PHPMaker 9.2.0, it has not the ability to hide the certain tabs you want. For example, I want to hide the certain tab by using the certain Server Events for the certain user levels which do not have permission to access the detail pages. I think this ability should be provided by PHPMaker by default, especially if the current user is forbidden to display the certain detail pages. The existing condition, the tab that belong to such restricted detail pages are still being shown, and below it will be shown "You do not have permission to access the page" message. I think this is not a good condition, and also so funny. It often makes your users get confused. They must be asking by themselves: "If this detail cannot be accessed, why then the tab was being displayed?". Indeed! LoL.
Well, I have successfully customized the extension to overcome this issue. After implementing the customization below, then all of the preview row tabs that belong to the restricted/forbidden details pages will be hidden automatically. You don't need to use any Server Events anymore for this! You don't need also to customize the generated script files at all as I always avoid it all the time! All we have to do is by customizing the template, so you can use it for your future PHPMaker projects.
Updated on June 17, 2013: The customization has been handled by using MasinoPreviewRow 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 \extensions\PreviewRow\renderoption.php file, and find this code:
$oListOpt->Body .= "var tab = new ewWidget.Tab({label: \"" . ew_JsEncode2($Language->TablePhrase("<!--##=sDetailTblVar##-->", "TblCaption")); <!--## if (bDetailShowCount) { ##--> $oListOpt->Body .= " " . ew_JsEncode2(str_replace("%c", $this-><!--##=sDetailTblVar##-->_Count, $Language->Phrase("DetailCount"))); <!--## } ##--> $oListOpt->Body .= "\", dataSrc: \"<!--##=sFnPreview##-->?f=" . TEAencrypt($sSqlWrk, EW_RANDOM_KEY) . "\""; $oListOpt->Body .= "}); tab._links = \"" . ew_JsEncode2($links) . "\"; tab._index = <!--##=k##-->; tab.loadHandler.success = ew_TabLoadSuccess; tabview.addTab(tab);";
then replace it with the following code:
// Begin of modification Hide Restricted Detail Preview Row Tab, by Masino Sinaga, February 27, 2013 if (IsLoggedIn()) { if ($Security->AllowList(CurrentProjectID() . '<!--##=sDetailTblVar##-->')) { $oListOpt->Body .= "var tab = new ewWidget.Tab({label: \"" . ew_JsEncode2($Language->TablePhrase("<!--##=sDetailTblVar##-->", "TblCaption")); <!--## if (bDetailShowCount) { ##--> $oListOpt->Body .= " " . ew_JsEncode2(str_replace("%c", $this-><!--##=sDetailTblVar##-->_Count, $Language->Phrase("DetailCount"))); <!--## } ##--> $oListOpt->Body .= "\", dataSrc: \"<!--##=sFnPreview##-->?f=" . TEAencrypt($sSqlWrk, EW_RANDOM_KEY) . "\""; $oListOpt->Body .= "}); tab._links = \"" . ew_JsEncode2($links) . "\"; tab._index = <!--##=k##-->; tab.loadHandler.success = ew_TabLoadSuccess; tabview.addTab(tab);"; } } else { $oListOpt->Body .= "var tab = new ewWidget.Tab({label: \"" . ew_JsEncode2($Language->TablePhrase("<!--##=sDetailTblVar##-->", "TblCaption")); <!--## if (bDetailShowCount) { ##--> $oListOpt->Body .= " " . ew_JsEncode2(str_replace("%c", $this-><!--##=sDetailTblVar##-->_Count, $Language->Phrase("DetailCount"))); <!--## } ##--> $oListOpt->Body .= "\", dataSrc: \"<!--##=sFnPreview##-->?f=" . TEAencrypt($sSqlWrk, EW_RANDOM_KEY) . "\""; $oListOpt->Body .= "}); tab._links = \"" . ew_JsEncode2($links) . "\"; tab._index = <!--##=k##-->; tab.loadHandler.success = ew_TabLoadSuccess; tabview.addTab(tab);"; } // End of modification Hide Restricted Detail Preview Row Tab, by Masino Sinaga, February 27, 2013
- As you can see from the replacement code above, the IsLoggedIn condition will handle the logged in users, whereas the else part will handle the anonymous users.
- Finally, re-generate your script files using PHPMaker as always.
[/hidepost]
Masino,
Is there a way to change the “plus sign” icon to something that is a bit more descriptive? Something like “Linked Detail” or something like it?
Yes. Simply customize the renderoption.php file that belongs to the previewrow extension, around line 102. There you can see the code to display the link with the “plus sign” in it. You can customize it to whatever you want.