Have you ever wanted to hide the action buttons on the View page of the web applications that generated by PHPMaker? The action buttons I meant is Add (also Copy if you enable it from Fields setup), Edit, and Delete. Now you can do it easily by using either Server Events or Client Scripts. Since PHPMaker version 10, this button have been groupped into a new term: Action.
This following trick will show you how you can hide all those buttons so easily and quickly by using two approachs. First by using Server Events, and the second is by using Client Scripts. This trick is useful is you want to hide those buttons only for the View page of the certain table. In other words, you don't have to touch the generated code. In addition, I shared this trick as well as my reply to the related topic on PHPMaker discussion forum.
The first approach is by using Server Events.
- Select the table from the Database pane, and then click on Code (Server Events, Client Scripts and Custom Templates) tab at the right side of PHPMaker application.
-
Expand the following location: Server Events -> Table-Specific -> View Page -> Page_Render, then copy the following code:
$this->OtherOptions["action"]->Items["add"]->Body = ""; $this->OtherOptions["action"]->Items["copy"]->Body = ""; $this->OtherOptions["action"]->Items["edit"]->Body = ""; $this->OtherOptions["action"]->Items["delete"]->Body = "";
- Re-generate your script files using PHPMaker, as always.
The second approach is by using Client Scripts.
- Select the table from the Database pane, and then click on Code (Server Events, Client Scripts and Custom Templates) tab at the right side of PHPMaker application.
-
Expand the following location: Client Scripts -> Table-Specific -> View Page -> Startup Script, then copy the following code:
$(document).ready(function() { $('.ewAdd').hide(); $('.ewCopy').hide(); $('.ewEdit').hide(); $('.ewDelete').hide(); });
- Re-generate your script files using PHPMaker, as always.
See? That's how easy we can achieve this by using PHPMaker. No need to write hundred lines of code! 🙂
Leave a Reply
You must be logged in to post a comment.