Show Message on Custom Page

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

Show Message on Custom Page

Post by wungaz »

Is there a way i can have the Show message function to work on a Custom file. If not possible, can I disable all Success or failure messages.
My system shows messages for example "Update succeeded" but it wont show on the custom page, it will show later on if you open another page that is not custom.

I want to disable all messages if possible and use only custom messages


danielc
User
Posts: 1601

Post by danielc »

You may need to customize the custom page to add back $yourcustompage_php->ShowMessage(); and function Message_Showing(). You can reference to other generated table's list page.


mobhar
User
Posts: 11745

Post by mobhar »

  1. Add this code at the top of "Content" of your custom file (assume your custom file name is "mycustom.php"):

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

  1. Customize the "custom.php" template file, find this code:

    //
    // Page main
    //
    function Page_Main() {
    // Set up Breadcrumb
    $this->SetupBreadcrumb();
    }

then replace it with the following code:

//
// Page main
//
function Page_Main() {
	// Set up Breadcrumb
	$this->SetupBreadcrumb();
}

// Message Showing event for Custom Files, added by Masino Sinaga, March 9, 2015
// $type = ''|'success'|'failure'|'warning'
function Message_Showing(&$msg, $type) {
	if ($type == 'success') {

		//$msg = "your success message";
	} elseif ($type == 'failure') {

		//$msg = "your failure message";
	} elseif ($type == 'warning') {

		//$msg = "your warning message";
	} else {

		//$msg = "your message";
	}
}

Please read also "Customizing Template" topic from PHPMaker Help menu for more information how to customize the template and zip it back.


wungaz
User
Posts: 214

Post by wungaz »

Works perfect...i was not adding the Message_Showing. But my only problem is the actual message. If you change //$msg = "your success message"; - the message keeps showing even without a success event.


Webmaster
User
Posts: 9429

Post by Webmaster »

To clear the message in Custom File, just clear the session variables:

$SESSION[EW_SESSION_MESSAGE] = "";
$
SESSION[EW_SESSION_FAILURE_MESSAGE] = "";
$SESSION[EW_SESSION_SUCCESS_MESSAGE] = "";
$
SESSION[EW_SESSION_WARNING_MESSAGE] = "";

To show the message just use <?php CurrentPage()->ShowMessage(); ?> in your content. (Adding Message_Showing() is unnecessary if you don't need to customize the message.)


Post Reply