Simple layout support in CodeIgniter 2.0
Simpler could be dangerous for your mental health.
<?php
class MY_Parser extends CI_Parser {
private $layout = 'main';
public function set_layout($layout)
{
if ( $layout != '' ) {
$this->layout = $layout;
}
}
public function parse($template, $data, $return = FALSE)
{
// First get the normal parsing
$data['content'] = parent::parse($template, $data, TRUE);
// Then parse again in the layout, duh !
return parent::parse('layout/'.$this->layout, $data, $return);
}
}
/* End of file MY_Parser.php */
/* Location: ./application/libraries/MY_Parser.php */
Written by Franco Bouly
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#