API15

API15:JError/customErrorPage

From Joomla! Documentation

Revision as of 22:18, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== Display a custom error page and exit gracefully <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JError/customErrorPage|Edit Descrip...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

Display a custom error page and exit gracefully

[Edit Descripton]

Template:Description:JError/customErrorPage

Syntax

customErrorPage(&$error)
Parameter Name Default Value Description
$error Exception object

Returns

void

Defined in

libraries/joomla/error/error.php

Importing

jimport( 'joomla.error.error' );

Source Body

function customErrorPage(& $error)
{
        // Initialize variables
        jimport('joomla.document.document');
        $app        = & JFactory::getApplication();
        $document       = & JDocument::getInstance('error');
        $config         = & JFactory::getConfig();

        //Get the current language direction
        $language = &JFactory::getLanguage();
        if ($language->isRTL()){
        $dir ="rtl";
        }
        else {
        $dir ="ltr";
        }

        // Get the current template from the application
        $template = $app->getTemplate();

        // Push the error object into the document
        $document->setError($error);

        @ob_end_clean();
        $document->setTitle(JText::_('Error').': '.$error->code);
        $document->setLanguage($language->getTag());
        $document->setDirection($dir);
        $data = $document->render(false, array (
                'template' => $template,
                'directory' => JPATH_THEMES,
                'debug' => $config->getValue('config.debug')
        ));

        JResponse::setBody($data);
        echo JResponse::toString();
        $app->close(0);
}

[Edit See Also] Template:SeeAlso:JError/customErrorPage

Examples

<CodeExamplesForm />