How to Create Error Handler in Joomla
Of cause, error handler will not save you from errors. But it can make error messages not so scare for users J
To create an error handler, you should create error.php file for template applied to your site.
If you use more than one template (default one and some additional template(s) for different site pages and/or sections), you need to create error.php for each of them. Put error.php to ../template/template_name folder, where template_name is a name of the used template.
Insert php code to error.php. For example,
<?php
defined ( ‘_JEXEC’ ) or die ( ‘Restricted index access’ );
if (($this->error->code) == ‘404’ || ($this->error->code) == ‘500’) {
header ( ‘Location: ‘ . $this->baseurl . ‘/404.html’ );
exit ();
}
will redirect user to 404.html in the case error 404 or 500 occurs.
Enjoy your errors!
humph! I did that, and got this error:
Parse error: syntax error, unexpected T_STRING in /…/templates/template_name/error.php on line 2
I tried to get a little fancy, this is the code from error.php
error->code) == ’404′ || ($this->error->code) == ’500′) {
header ( ‘Location: ‘ . $this->baseurl . ‘/notfound’ );
exit ();
}
in the root .htaccess I have a redirect for biketexas.org/notfound to a specific article that gives an error message.