How to access smarty library in third party folder using Codeigniter?
You will need to create a library class to extend smarty and autoload that. In your /application/library/
folder create a new file called smartylib.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');// path to SMARTY libraryinclude APPPATH.'thirdparty/Smarty/libs/Smarty.class.php';class Smartylib extends Smarty { function __construct() { parent::__construct(); }}
Then autoload it in your autoload.php
$autoload['libraries'] = array('smartylib');
You may be required to do some config stuff for Smarty in your construct. Take a look at the Smarty Documentation on extending smarty
You will then be able to use it in your controller:
$this->smartylib->assign('name','Ned');$this->smartylib->display('index.tpl');
Further, if you like or need to use as
$this->smarty->assign('name', 'Ned');
Please CLONE the 'smartylib' object into 'smarty' on the Controller __Consructor()
function
$this->smarty = clone $this->smartylib;