gb
12-13-2005, 01:53 PM
I have implemented custom error pages that are handled by a template. I need to do that for the different languages.
Let me know if this makes sense to you than I will remove the suggested from the title.
1.) Create file in root called "error.php"
Content:
<?php
/************************************************** *************************
*
* IMPORTANT: This program is a commercial software and any kind of using
* it must agree to eSyndiCat license agreement. It can be found here:
* http://www.esyndicat.com/license.html
*
* This notice may not be removed from the source code.
*
* Copyright 2005 eSyndiCat Software Development Ltd.
* http://www.esyndicat.com/
*
************************************************** *************************/
require_once('classes/Dir.php');
require_once('includes/auth.inc.php');
require_once('templates/'.$gDirConfig['tmpl'].'/Layout.php');
require_once('classes/DirSmarty.php');
require_once('util.php');
/** defines page title **/
$gDirSmarty->assign_by_ref('title', $gDirLang['error']);
/** menu display **/
$gDirSmarty->assign_by_ref('menu', $gDirLayout->print_menu());
/** gets error **/
$category =& $gDirDb->getCategoryByPath($_GET['error']);
$gDirSmarty->assign_by_ref('error', $_GET['error']);
/** breadcrumb formation **/
$bc['help']['url'] = '';
$bc['help']['caption'] = $gDirLang['error'];
$breadcrumb = $gDirLayout->print_breadcrumb(0, $bc, 1);
$gDirSmarty->assign_by_ref('breadcrumb', $breadcrumb);
$gDirSmarty->display('error.tpl');
?>
2.) in the .htaccess file in the root directory add the following lines at the end
RewriteRule ^([0-9]+).htm$ error.php?error=$1 [QSA,L]
ErrorDocument 500 /500.htm
ErrorDocument 404 /404.htm
ErrorDocument 403 /403.htm
ErrorDocument 401 /401.htm
3.) Creat a template in your templates folder called "error.tpl"
Content of this file (basic - modify to your own needs):
{include file="header.tpl"}
<h1>{$lang.error} {$error}</h1>
{$error}
{include file="footer.tpl"}
4.) In your language file (ex. English.php) create a new line
'error' => 'Error',
To take this a step further you can create language entries for the error text that should be displayed for the different errors
like:
'404' => 'File not found',
'403' => 'Access Denied',
'401' => 'Unauthorized',
'500' => 'Page not Available',
and include the text dynamically in your error.tpl like
{$lang.$error}
Greetings,
gb
Let me know if this makes sense to you than I will remove the suggested from the title.
1.) Create file in root called "error.php"
Content:
<?php
/************************************************** *************************
*
* IMPORTANT: This program is a commercial software and any kind of using
* it must agree to eSyndiCat license agreement. It can be found here:
* http://www.esyndicat.com/license.html
*
* This notice may not be removed from the source code.
*
* Copyright 2005 eSyndiCat Software Development Ltd.
* http://www.esyndicat.com/
*
************************************************** *************************/
require_once('classes/Dir.php');
require_once('includes/auth.inc.php');
require_once('templates/'.$gDirConfig['tmpl'].'/Layout.php');
require_once('classes/DirSmarty.php');
require_once('util.php');
/** defines page title **/
$gDirSmarty->assign_by_ref('title', $gDirLang['error']);
/** menu display **/
$gDirSmarty->assign_by_ref('menu', $gDirLayout->print_menu());
/** gets error **/
$category =& $gDirDb->getCategoryByPath($_GET['error']);
$gDirSmarty->assign_by_ref('error', $_GET['error']);
/** breadcrumb formation **/
$bc['help']['url'] = '';
$bc['help']['caption'] = $gDirLang['error'];
$breadcrumb = $gDirLayout->print_breadcrumb(0, $bc, 1);
$gDirSmarty->assign_by_ref('breadcrumb', $breadcrumb);
$gDirSmarty->display('error.tpl');
?>
2.) in the .htaccess file in the root directory add the following lines at the end
RewriteRule ^([0-9]+).htm$ error.php?error=$1 [QSA,L]
ErrorDocument 500 /500.htm
ErrorDocument 404 /404.htm
ErrorDocument 403 /403.htm
ErrorDocument 401 /401.htm
3.) Creat a template in your templates folder called "error.tpl"
Content of this file (basic - modify to your own needs):
{include file="header.tpl"}
<h1>{$lang.error} {$error}</h1>
{$error}
{include file="footer.tpl"}
4.) In your language file (ex. English.php) create a new line
'error' => 'Error',
To take this a step further you can create language entries for the error text that should be displayed for the different errors
like:
'404' => 'File not found',
'403' => 'Access Denied',
'401' => 'Unauthorized',
'500' => 'Page not Available',
and include the text dynamically in your error.tpl like
{$lang.$error}
Greetings,
gb