HTML and CSS Reference
In-Depth Information
* Loads and outputs the view's markup
* @return void
abstract public function output_view( );
The __construct() method checks for an array of options (which will be the array extracted by parse_uri() in
index.php ) and throws an Exception if none was supplied.
For the moment, the generate_nonce() method simply returns a temporary string. You will revisit this method in
the “Handling Form Submissions” section later in this chapter.
The sanitize() method does some very basic input sanitization, which should always be performed on
user-supplied data.
Later in this chapter, you'll build a controller that extends this class, but first you'll need a way to handle views
(or else the output_view() method will break).
Creating the View Class
In order to show output, you'll need a View class. This class will, in essence, load the views requested by the
Controller class and return them. However, because the data being displayed will vary from room to room, the
View class also needs to insert data into the views; this will require a simple setter implementation, which we'll
discuss a bit later.
In the system/core/ subdirectory, create a new file called . Inside, add the following code:
* Parses template files with loaded data to output HTML markup
* @author Jason Lengstorf <>
* @author Phil Leggetter <>
class View
protected $view,
$vars = array();
* Initializes the view
* @param $view array The view slug
* @return void
public function __construct( $view=NULL ) {
if (!$view) {
throw new Exception("No view slug was supplied.");
Search WWH ::

Custom Search