Customise Modal Dialog Title and Button Caption (v2017)

Tips submitted by PHPMaker users

Customise Modal Dialog Title and Button Caption (v2017)

Postby kirondedshem » Fri May 05, 2017 4:16 pm

Am sorry for this is my first post so bear with me:

When you enable modal dialog on add, edit or view of a table a view, it will cause the add, edit and view forms to appear in a modal dialog.
By default the header caption and button caption when using modal dialog Add, edit and view are Add,Edit and View respectively.
LOGIC: the addlink,editlink,viewlink phrase is used to determine the DEFAULT header title and button captions of the modal dialogs respectively

IN page_load EVENT of the List page of the desired table or view PUT
NOTE: This alone will change the Header Title and the Button Caption on the respective modal dialog

// Page Load event
function Page_Load() {
//echo "Page Load";
$GLOBALS["Language"]->SetPhrase("addlink","Add Dialog Title");
$GLOBALS["Language"]->SetPhrase("editlink","Edit Dialog Title");
$GLOBALS["Language"]->SetPhrase("viewlink","View Dialog Title");
}

Now if you want to customize ONLY the button caption on the modal dialog Add
LOGIC: If you inspect the add link on the list page you will find a parameter passed in javascript called caption:'Add' during onclick of the buttons. This is what is used as the button caption on the modal dialog respectively, what we do is edit the html of the button link before it is drawn

FOR ADD LINK PUT IN Page_Render OR Page_DataRendering of the List page of the desired table or view PUT
// Page Render event
function Page_Render() {
//echo "Page Render";
$addlink = $GLOBALS["Language"]->Phrase("addlink",TRUE); //ask for ONLY THE TEXT VALUE of the phrase
$this->OtherOptions["addedit"]->Items["add"]->Body = str_replace("caption:'$addlink'","caption:'Add Button Caption'", $this->OtherOptions["addedit"]->Items["add"]->Body);
}


Now if you want to customize the ONLY the button caption on the modal dialog Edit
LOGIC: If you inspect the edit link for a given record on the list page you will find a parameter passed in javascript called caption:'Edit' during onclick of the buttons. This is what is used as the button caption on the modal dialog respectively, what we do is edit the html of the button link before it is drawn

FOR EDIT IN ListOptions_Rendered of the List page of the desired table or view, SINCE IT IS DRAWN DIFFERENT FOR EVERY RECORD PUT

// ListOptions Rendered event
function ListOptions_Rendered() {
// Example:
//$this->ListOptions->Items["new"]->Body = "xxx";
$editlink = $GLOBALS["Language"]->Phrase("editlink",TRUE); //ask for ONLY THE TEXT VALUE of the phrase
$this->ListOptions->Items["edit"]->Body = str_replace("caption:'$editlink'","caption:'Edit Button Caption'", $this->ListOptions->Items["edit"]->Body);

}


EXTRA NOTES:
For non modal add, edit and view forms, you only need to set phrases (add,addbtn) (edit,savebtn) (view) in the page_load event of the add,edit and view pages respectively.
You can also use this method to customise ONLY the hover text on those links.
You can get even more creative if you use var_dump() during any event, this can allow you to inspect how php maker is planing to setup anything and you can see which properties you need to tweak to get your needs
kirondedshem
 
Posts: 310
Joined: Sat Jan 28, 2017 7:13 pm

Re: Customise Modal Dialog Title and Button Caption v2017

Postby yeico » Tue Jun 13, 2017 11:23 am

Thanks very much!!!. Great for me.
yeico
 
Posts: 11
Joined: Wed Nov 21, 2012 3:46 am

Re: Customise Modal Dialog Title and Button Caption (v2017)

Postby davor » Mon Jul 17, 2017 2:12 pm

Veri nice idea, actually this is something it is very imaportant for any project.
For some reason it doesnt vork for me so if you can only help a bit.
As far I understood there are onyl two things to do:
1. to create tbale in the database (and ganerate it on the php maker) and
2. to copy this code to CleintScripts, Global, Startup Script.
Is there anything else to do? When I click on the green question mark it just nothing happens, and the broeser keep doing it something in the back.
(At Inspect page it is written: Error: "Syntax error, unrecognized expression: [{"url":"help_documentlist.php"}]" for all pages I click)
Help please?

Davor
davor
 
Posts: 18
Joined: Wed Jun 04, 2014 5:19 am

Re: Customise Modal Dialog Title and Button Caption (v2017)

Postby kirondedshem » Tue Jul 18, 2017 7:18 pm

@davor, you wrote this reply in the wrong thread, I will post a reply on the correct thread with heading "Dynamic content sensitive Help Content or User Guide"
kirondedshem
 
Posts: 310
Joined: Sat Jan 28, 2017 7:13 pm


Return to User Submitted Tips (PHPMaker)