This following trick will show you how to hide the "Add" link in the web applications that generated by PHPMaker. Sometimes you do not want to show the "Add" link for the certain table since you want to use "Grid Add" link in order to add records using the Grid-Add feature. Well, we can achieve it by using the "Server Events" provided by PHPMaker.
In addition, this trick also will disable the functionality of "Add" page so we can prevent users to access that page by typing its address directly from the browser. In other words, when users are trying to access the "Add" page directly, then they will automatically be redirected to (for example) the "Grid Add" page. This will prevent the cheating users who will try to access the "Add" page directly by typing its URL Address.
We will use "Server Events" for this purpose. The advantage you will get is you can learn how to optimize the "Server Events" in order to hide the certain links on the fly without having to modify the generated script files. Actually, you can also hide the similar links, such as "Delete" that located outside of the table in the List/View page.
In this example, assume we use orders table as provided by PHPMaker in its demo website.
Updated on February 10, 2013: This customization has been implemented in PHPMaker version 9.2.0, it matches to each other, and as a result, it works properly.
[hidepost]
- Open your PHPMaker project (.pmp) file using PHPMaker as always.
-
Click on your desired table, then click on Code (Server Events, Client Scripts and Custom Templates) tab, and expand this location: Server Events -> Table-Specific -> Common -> Row_Rendered, and then insert the following code:
$this->AddUrl = "";that code will hide the "Add" link in the pages other than the List page.
-
Still in the Server Events, go to: Table-Specific -> Add/Copy Page -> Page_Load, and then insert the following code:
if (@$_GET["showdetail"]=="") { $this->Page_Terminate("ordersadd.php?showdetail=order_details"); }that code said, if there is no value of showdetail in the URL, which means users are trying to access the normal "Add" page, then redirect them to the Orders/Order Details page. Of course, you can adjust it that suits to your needs.
-
Still in the Server Events, go to: Table-Specific -> List Page -> ListOptions_Load, and then insert the following code:
$this->AddUrl = "";that code will hide the "Add" link in the List page.
- Finally, save your project, and then re-generate your script files using PHPMaker as always.
[/hidepost]
Leave a Reply
You must be logged in to post a comment.