Simple template library with some core functionalities to simplify the development process for CodeIgniter 2.x.
- Extract all files to your project root directory. Make sure to overwrite all files if prompted.
- Open
app/config/autoload.php
, add'template'
to$autoload['libraries']
and$autoload['config']
. - Edit your template configuration file
application/config/template.php
. - Navigate to
yourwebsite.dev/index.php/welcome
.
Template library handles most of the views logic on its own.
With simple $this->template->load();
call inside the controller's method, it will automatically create pagetitle
, pagename
, scripts
, stylesheets
variables and subload a corresponding subview file controller/method.php
if nothing was provided in load()
function.
Load custom view file:
$this->template->load('path/to/view.php');
Load custom view file within a custom template file:
$this->template->load('template/login', 'user/login/form');
Set custom page title:
$this->template->title('Product page');
Set custom breadcrumbs:
$this->template->crumb('E-commerce', 'ecommerce/index');
$this->template->crumb('Products', 'ecommerce/products');
$this->template->crumb('Product #391');
Add custom JavaScript file loading:
$this->template->script('plugin/head.js', TRUE)
$this->template->script('footer.js');
Add custom CSS file loading:
$this->template->css('print.css', 'print');
Set custom variables:
$this->template->set_item('articles', $articles);
// Now you are able to use $articles
inside all subviews