Customise Modal Dialog Title and Button Caption (v2017)

Tips submitted by PHPMaker users
Post Reply
kirondedshem
User
Posts: 642

Customise Modal Dialog Title and Button Caption (v2017)

Post by kirondedshem »

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


yeico
User
Posts: 20

Post by yeico »

Thanks very much!!!. Great for me.


davor
User
Posts: 17

Post by davor »

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


kirondedshem
User
Posts: 642

Post by kirondedshem »

@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"


ghasembaghi
User
Posts: 293

Post by ghasembaghi »

change all table
//Server Event > Global
function Page_Rendering() {
//echo "Page Rendering";
GLOBAL $Language;
if(CurrentPageID()=='list'){
$Language->SetPhrase('addlink', HtmlTitle($Language->phrase('addlink')) .' '. CurrentPageHeading());
$Language->SetPhrase('editlink', HtmlTitle($Language->phrase('editlink')) .' '. CurrentPageHeading());
$Language->SetPhrase('viewlink', HtmlTitle($Language->phrase('viewlink')) .' '. CurrentPageHeading());
}

}

Post Reply