Quote:
Originally Posted by frosty1
i use this very simple helper to handle my errors. it saves the errors to a session so you dont have to worry about redirects clearing the error.
PHP Code:
<?php
class libErrors
{
private $ns;
private $errors;
function __construct()
{
$this->ns = new Zend_Session_Namespace('errors');
$this->errors = $this->ns->errors;
}
function clear()
{
unset($this->errors);
$this->updateNs();
}
function add($error)
{
$this->errors[] = $error;
$this->updateNs();
}
function hasErrors()
{
if(count($this->errors) > 0){
return true;
}
}
function get()
{
return $this->errors;
}
private function updateNs()
{
$this->ns->errors = $this->errors;
}
}
i then use this view helper, renderAlert (which handles both errors and messages to the user)
PHP Code:
public function RenderAlert(){
$m = new libMessage();
$e = new libErrors();
$alert = false;
$view = Zend_Registry::get('view');
if($m->hasMessage() || $e->hasErrors()){
if($m->hasMessage()){
$message = "<p>" . $m->get() . "</p>";
}
if($e->hasErrors()){
$error = "<p>The following errors have occurred:</p>" . $view->HtmlList($e->get());
}
$alert = "<div class='message_box'>" . $message . $error . "</div>";
}
//after this renders it clears the errors and messages
$m->clear();
$e->clear();
return $alert;
}
|
I think that's very interesting, i have made something like this. I have a utility class, and one of its methotds is a message method who puts a class (for icon), title and message on session, and i have a "session" on my header who show the message, another way to show the message is using javascript, a few effects with Script.aculo.us made it a lot more pretty

People here thinks thats cool. And we are making the second system with that.
Sorry for my english.
P.S.: I love to have found that forum.
Hugs.