Page Class
The Page class is a small class with one main function: To send the render the <HEAD> and <BODY> segment and send it to the Output class. It is responsible for pre-caching your web pages, and is required for JavaScript and AJAX.
Note: This class is initialized automatically by the system so there is no need to do it manually.
Under normal circumstances you won't even notice the Page class since it works transparently without your intervention. For example, when you use the Loader class to load a view file, it's automatically passed to the Output class, which will be called automatically by HerbIgniter at the end of system execution. You will use this class to distinguish between <HEAD> code and <BODY> code. When you use a loaded view, you will need to pass the optional parameter TRUE to insert a view into the body segment like: $this->page->append_body( $this->load->view('someview', true) );
$this->page->set_head();
Permits you to manually set the Page's <HEAD> output. Usage example:
$this->output->set_head($data);
$this->page->get_head();
Permits you to manually retrieve any <HEAD> content that has been sent for storage in the Page class's <HEAD> buffer. Usage example:
$string = $this->output->get_head();
$this->page->append_head();
Appends output to storage in the Page class's <HEAD> buffer. Usage example:
$string = $this->output->append_head( '<META>...');
$this->page->set_body();
Permits you to manually set the content of the <BODY> tag. Usage example:
$this->output->set_output($data);
Important: If you do set your output manually, it must be the last thing done in the function you call it from. For example, if you build a page in one of your controller functions, don't set the output until the end.
$this->page->get_body();
Permits you to manually retrieve any output that has been sent for storage in the Page class's <BODY> buffer. Usage example:
$string = $this->output->get_body();
$this->page->append_body();
Permits you to append some code to the final <BODY> output string. Usage example:
$this->output->append_body($code);
$this->output->set_header();
Permits you to manually set server headers, which the output class will send for you when outputting the final rendered display. This is part of the Output class. Example:
$this->output->set_header("HTTP/1.0 200 OK");
$this->output->set_header("HTTP/1.1 200 OK");
$this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_update).' GMT');
$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
$this->output->set_header("Cache-Control: post-check=0, pre-check=0");
$this->output->set_header("Pragma: no-cache");
$this->output->set_status_header(code, 'text');
Permits you to manually set a server status header. Example:
$this->output->set_status_header('401');
// Sets the header as: Unauthorized
See here for a full list of headers.
$this->output->enable_profiler();
Permits you to enable/disable the Profiler, which will display benchmark and other data at the bottom of your pages for debugging and optimization purposes.
To enable the profiler place the following function anywhere within your Object functions:
$this->output->enable_profiler(TRUE);
When enabled a report will be generated and inserted at the bottom of your pages.
To disable the profiler you will use:
$this->output->enable_profiler(FALSE);
The HerbIgniter output library also controls caching. For more information, please see the caching documentation.