Welcome Guest, Not a member yet? Register   Sign In
Template library for CD3
#5

(This post was last modified: 09-04-2015, 05:19 PM by rtorralba.)

(09-04-2015, 04:54 PM)Camo Wrote: Thanks, but I need some examples how implement it to the CI. Syntax is no problem so it would be better to use something robust. But main is the documentation for CI.

You simply can use it with composer:
  • You must to have installed composer https://getcomposer.org/doc/00-intro.md#...x-unix-osx
  • Then go to the application folder and execute: 

    Code:
    composer require league/plates


  • Edit ci config.php and set TRUE $config['composer_autoload'].
  • At controller, I recommend at MY_Controller if you use this templates at all controllers, initialize the plates class:
PHP Code:
class MY_Controller extends CI_Controller
{
 
   protected $templates;

    function __construct()
    {
        parent::__construct();
 
       
        
// The parameter is the views path, in the example I put the default
 
       // codeigniter views path
        $this->templates = new League\Plates\Engine(APPPATH.'views');
    }

  • Finally call render method of plates:
PHP Code:
class Example_Controller extends MY_Controller
{
 
 public function index()
 
 {
 
   $data = array('key' => 'value');
 
   $this->templates->render('view_name'$data);
 
 }

Greetings.
Reply


Messages In This Thread
Template library for CD3 - by Camo - 09-03-2015, 06:18 PM
RE: Template library for CD3 - by Camo - 09-04-2015, 11:38 AM
RE: Template library for CD3 - by rtorralba - 09-04-2015, 01:59 PM
RE: Template library for CD3 - by Camo - 09-04-2015, 04:54 PM
RE: Template library for CD3 - by rtorralba - 09-04-2015, 05:12 PM
RE: Template library for CD3 - by Camo - 09-04-2015, 05:27 PM
RE: Template library for CD3 - by rtorralba - 09-04-2015, 05:49 PM
RE: Template library for CD3 - by Camo - 09-04-2015, 06:34 PM
RE: Template library for CD3 - by rtorralba - 09-05-2015, 02:28 AM



Theme © iAndrew 2016 - Forum software by © MyBB