How to set success message,terminate page from global code

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
Bishu
User
Posts: 432

How to set success message,terminate page from global code

Post by Bishu »

I am writing a function in the global code and in the function I have to set a success message and terminate the page.
e.g.

function myfunction(){


-----------------------------
$this->setSuccessMessage("Success");
$this->Page_Terminate("myurl");
}

Here I got a message as
"Fatal error: Using $this when not in object context in C:\wamp\www\cashsms\backend\userfn10.php on line 42"
As my function is in the global code $this is not in the object.
how can I handle this situation.


Bishu
User
Posts: 432

Post by Bishu »

sorry for my silly question.

$this should be CurrentTable()


mobhar
User
Posts: 11905

Post by mobhar »

Yep, as the help file said:

"If a server event is a global function, there is NO "$this" in the function context. If you want to refer to the current page object, you can use the global function CurrentPage()."

CurrentPage()->setSuccessMessage("Success");
CurrentPage()->Page_Terminate("myurl");


Post Reply