CodeIgniter 2+ Simple Template Library
Simple template library with some core functionalities to simplify the development process for CodeIgniter 2.x., (*1)
How to use
- 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., (*2)
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., (*3)
Documentation
Load custom view file:br/
$this->template->load('path/to/view.php');, (*4)
Load custom view file within a custom template file:br/
$this->template->load('template/login', 'user/login/form');, (*5)
Set custom page title:br/
$this->template->title('Product page');, (*6)
Set custom breadcrumbs:br/
$this->template->crumb('E-commerce', 'ecommerce/index');br/
$this->template->crumb('Products', 'ecommerce/products');br/
$this->template->crumb('Product #391');, (*7)
Add custom JavaScript file loading:br/
$this->template->script('plugin/head.js', TRUE)br/
$this->template->script('footer.js');, (*8)
Add custom CSS file loading:br/
$this->template->css('print.css', 'print');, (*9)
Set custom variables:br/
$this->template->set_item('articles', $articles); // Now you are able to use $articles inside all subviews, (*10)