HTML and CSS Reference
In-Depth Information
public function get_title( )
{
return 'Something went wrong.';
}
/**
* Loads and outputs the view's markup
*
* @return void
*/
public function output_view( )
{
$view = new View('error');
$view->message = $this->_message;
$view->home_link = APP_URI;
$view->render();
}
}
The Error class is a little different in that it declares a private property
$_message
that will store the
Exception
class' error message.
The constructor stores the supplied error message in
$_message
if one is supplied, and
get_title()
returns a
generic error message for the
<title>
tag.
The
view()
method simply adds the error message and home page URI to the view object for use in the markup;
then renders the output.
Creating the Error View
To display the results of the
Error
controller, create a new file in
system/views/
called
error.inc.php
and add the
following markup:
<section id="error">
<h2>
I’m sorry, Dave.<br />
I’m afraid I can’t do that.
</h2>
<p>
Sorry, but something went wrong. Maybe the error message below
will help.
</p>
<p><code>
<?php echo $message; ?>
</code></p>
<p>
<a href="
<?php echo $home_link; ?>
">← go back to the home page</a>
</p>
</section>
Search WWH ::
Custom Search