Statusmessages using atkFeedback: Difference between revisions
No edit summary |
mNo edit summary |
||
| (7 intermediate revisions by 5 users not shown) | |||
| Line 1: | Line 1: | ||
{{howto|Easy|[[BERT]]}} | {{howto|Easy|[[BERT]]}} | ||
== Default feedback == | |||
If you have the need to disclose a message after an action (like save or cancel) and easy way to accomplish this is to use the setFeedback. | If you have the need to disclose a message after an action (like save or cancel) and easy way to accomplish this is to use the setFeedback. | ||
| Line 5: | Line 7: | ||
The following triggers the update_success message to disclose, you can also add additional information which is discloses below the normal message. | The following triggers the update_success message to disclose, you can also add additional information which is discloses below the normal message. | ||
<syntaxhighlight lang="php"> | |||
//enable feedback from post or pre Update or Add | //enable feedback from post or pre Update or Add | ||
$this->setFeedback("update", ACTION_SUCCESS); | $this->setFeedback("update", ACTION_SUCCESS); | ||
</syntaxhighlight> | |||
The actions you can use are update, save, delete, import. | |||
The status values are ACTION_SUCCESS, ACTION_FAILED, ACTION_CANCELED. | |||
== Custom feedback == | |||
If you need to add custom feedbacklogic, such as a constructed message, use the following: | |||
function feedbackUrl ($action, $status, $record="", $message=""){ | <syntaxhighlight lang="php"> | ||
public function feedbackUrl ($action, $status, $record="", $message="", $levelskip=1) | |||
{ | |||
// create a hyper link to goto the account edit page | // create a hyper link to goto the account edit page | ||
$xxx = href(dispatch_url("accounts.account", "edit", | |||
array('atkselector'=>'account.id='.$this->v_accountID )), | array('atkselector'=>'account.id='.$this->v_accountID )), | ||
"Edit Record", SESSION_DEFAULT ); | "Edit Record", SESSION_DEFAULT ); | ||
$message = "To directly edit Account press this link ".$xxx; | $message = "To directly edit Account press this link ".$xxx; | ||
return atkNode::feedbackUrl ($action, $status, $record, $message); | return atkNode::feedbackUrl ($action, $status, $record, $message, $levelskip); | ||
} | } | ||
</syntaxhighlight> | |||
You can change the default message for all nodes by adding it to your language file, here are the list of feedback message tags: | You can change the default message for all nodes by adding it to your language file, here are the list of feedback message tags: | ||
| Line 28: | Line 39: | ||
"feedback_update_success" | "feedback_update_success" | ||
Remember you can override an individule nodes value by appending the node name to the front of the tag. | Remember you can override an individule nodes value by appending the node name to the front of the tag, i.e. "<nodename>_feedback_update_success". | ||
Examples: | |||
"preaccount_feedback_update_success" => "An account has been created." // override for preaccount | * "feedback_update_success" => "Record has been successfully changed." // all nodes in module | ||
* "preaccount_feedback_update_success" => "An account has been created." // override for preaccount | |||
Latest revision as of 14:24, 18 February 2010
|
ATK Howto: Statusmessages using atkFeedback
|
Default feedback
If you have the need to disclose a message after an action (like save or cancel) and easy way to accomplish this is to use the setFeedback.
The following triggers the update_success message to disclose, you can also add additional information which is discloses below the normal message.
//enable feedback from post or pre Update or Add
$this->setFeedback("update", ACTION_SUCCESS);
The actions you can use are update, save, delete, import. The status values are ACTION_SUCCESS, ACTION_FAILED, ACTION_CANCELED.
Custom feedback
If you need to add custom feedbacklogic, such as a constructed message, use the following:
public function feedbackUrl ($action, $status, $record="", $message="", $levelskip=1)
{
// create a hyper link to goto the account edit page
$xxx = href(dispatch_url("accounts.account", "edit",
array('atkselector'=>'account.id='.$this->v_accountID )),
"Edit Record", SESSION_DEFAULT );
$message = "To directly edit Account press this link ".$xxx;
return atkNode::feedbackUrl ($action, $status, $record, $message, $levelskip);
}
You can change the default message for all nodes by adding it to your language file, here are the list of feedback message tags:
"feedback_delete_cancelled", "feedback_delete_failed", "feedback_delete_success" "feedback_import_failed", "feedback_save_cancelled", "feedback_save_failed" "feedback_save_success", "feedback_update_cancelled", "feedback_update_failed" "feedback_update_success"
Remember you can override an individule nodes value by appending the node name to the front of the tag, i.e. "<nodename>_feedback_update_success".
Examples:
- "feedback_update_success" => "Record has been successfully changed." // all nodes in module
- "preaccount_feedback_update_success" => "An account has been created." // override for preaccount