-
Notifications
You must be signed in to change notification settings - Fork 26
codeigniter template
[h3] Overview [/h3] This tutorial is based on Phil Sturgeon's template and themeing library which can be found at: http://github.com/philsturgeon/codeigniter-template
[h3] Installation [/h3] After downloading the codeigniter-template package from github, unpack it to the correct library/helper/config directory locations.
[h3] Example1: Basic Templating [/h3]
- Create the directory applications/views/base/ and add a layout.php file including a basic html layout such as: [code]
<html > <head> echo $template['partials']['header']; </head> <body> <?php $this->load->view('base/') ?> <?php echo $template['body']; ?> </body> </html> [/code]
-
Create the directory applications/views/basic/partials and add a header.php file in there including your css and metadata stuff, for example: [code] <title> Example Site </title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> [/code]
-
in MY_Controller add to the constructor the template configuration, for example: [code] function __construct() { parent::Controller();
$this->template->set_layout('base/layout'); $this->template->enable_parser(FALSE); // default true $this->template->set_partial('header', 'base/partials/header', FALSE);} [/code]
-
in your controller, whatever it may be, you should extend MY_Controller obviously and for the index function you should use: [code] $this->template->build('base/index', $data); [/code] where base/index is the view file in the module's views/base/ directory