Custom Error

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

Custom Error

Post by elazarus3 »

I am using custom files, and on several tables redirect to the custom file after add / edit. The custom file includes common files. However, when the custom file loads, the stored message (add succeeded, etc) doesn't show. It then shows inappropriately when I leave the custom file and go to a standard phpmaker list page.

Is there a way to clear the customerror so it doesn't display, or to get the success or failure message to display on my custom page?

Thanks.


mobhar
User
Posts: 11745

Post by mobhar »

To display the message that stored in session, then you need to call "ShowMessage()" method that belongs to the custom file class page.

Let's say your custom file is "home.php", then PHPMaker will use "$home_php" as the object page variable, and you need to insert the following code into your custom file:

<?php
$home_php->ShowMessage();
?>


elazarus3
User
Posts: 90

Post by elazarus3 »

Thanks - trying this but getting error. Page name is myjournal.php, so I added the code
$myjournal_php->ShowMessage();

at the beginning of the file's php code.

Getting this error:

Fatal error: Call to undefined method cmyjournal_php::Message_Showing() in C:\Dropbox\xampp\htdocs\patient_portal\myjournal.php on line 84

Any thoughts?


mobhar
User
Posts: 11745

Post by mobhar »

Did you put your additional code from the generated custom file, OR from inside of PHPMaker project then regenerate the script file?


elazarus3
User
Posts: 90

Post by elazarus3 »

Thanks - I've tried it both ways and get same error. In custom file => content, and in the actual file.


mobhar
User
Posts: 11745

Post by mobhar »

I know that this is actually not recommended, but please at the moment, try add this code in the generated custom file:

function Message_Showing(&$msg, $type) {

	// Example:
	//if ($type == 'success') $msg = "your success message";

}

inside the "cmyjournal_php" class. In other words, the additional code above must be the same level with the function ShowMessage itself.


elazarus3
User
Posts: 90

Post by elazarus3 »

Thanks so much for the tip, but still no luck :-(


mobhar
User
Posts: 11745

Post by mobhar »

I just tried on here, and it works properly.

I can see the custom message is shown when the page that created by Custom File is displayed.


elazarus3
User
Posts: 90

Post by elazarus3 »

Hmmm. Maybe I'm not being clear. So, let's say I have a custom page called journalhome. Another page, daily_journal redirects to journalhome after add/edit.

When I add a record to daily_journal, the success/error message (like add successful), etc - doesn't show on the journalhome page.

However, If I navigate away from that page to another area (like patient_list), when I click the patient_list list view, I get the "add successful" message - see - it is coming late, on the wrong screen.

Can I add a line of PHP code to journalhome that just clears all these messages? Or, how do I add code to journalhome to display the success message from daily_journal.

thanks!


mobhar
User
Posts: 11745

Post by mobhar »

I know exactly about your needs since the first post of yours. I also tried on my side, and there is nothing issue about displaying message in the generated page of Custom Files.


Post Reply