Welcome Guest, Not a member yet? Register   Sign In
show_error : Different display types
#1

[eluser]louis w[/eluser]
Firstly, where is the show_error function located? I did a quick browse in system and could not find it.

It would be nice if we could pass in a second param to switch the error template. I am working on a cms which will have two output formats for each page, HTML and XML. I wanted to change the show_error output to suit this.
#2

[eluser]Kromack[/eluser]
Hello,

this function is in system/libraries/Exceptions.php.

Have you read the user guide about how to extend native CI libraries ? Because you can make your own show_error() function Wink
#3

[eluser]louis w[/eluser]
I know this, thats why I was asking where it was located. Thanks.
#4

[eluser]louis w[/eluser]
Code:
function show_error($heading, $message, $template = 'error_general')

Niceee, looks like it already supports template switching.
#5

[eluser]louis w[/eluser]
I do not think the CI_Exceptions show_error is the same as the regular show_error.

Both of these just display "Some Error" and do not pay attention to the second param ($message).

show_error('Some Error', 'Whatever');
show_error('Some Error', array('Whatever', 'You want.'));
#6

[eluser]Pascal Kriete[/eluser]
The global show_error function is found in system/codeigniter/common.php . It uses the exceptions class to display the error, but always uses the default template with a heading of "An error was encountered". If you want a custom template use:
Code:
$error =& load_class('Exceptions');
echo $error->show_error('My Heading', 'My Message', 'My Template');
#7

[eluser]louis w[/eluser]
Interesting, ok.
And I would suppose that files in /codeigniter/ can not be overridden with the MY_ prefix in app?


[quote author="inparo" date="1210129317"]The global show_error function is found in system/codeigniter/common.php . It uses the exceptions class to display the error, but always uses the default template with a heading of "An error was encountered". If you want a custom template use:
Code:
$error =& load_class('Exceptions');
echo $error->show_error('My Heading', 'My Message', 'My Template');
[/quote]




Theme © iAndrew 2016 - Forum software by © MyBB