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

(This post was last modified: 09-04-2015, 11:40 AM by Camo.)

Meanwhile I wrote my own solution. 
But please can you tell me where I can find some libraries for CD3 ie. template lib? 

I am totally newbie in CD. I go according one very old tutorial and is not actual as you can surmise. 

This is my:


PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


/**
* Name: Template
*
* Version: 1.0.0
*
* Author: Vladimír Čamaj
[email protected]
* @camo
*
* Requirements: PHP5 or above
*
*/

class template
{
 
/**
 * @desc Array of keys witch will be converted to variables in templates
 * @var array
 */
 
protected $data = array('title' => 'Welcome to Codeigniter');


 
/**
 * @desc Instance of controller
 * @var Object
 */
 
protected $ci;



 
/**
 * @desc Sets the instance of controller in to the ci variable.
 */
 
public function __construct()
 {
 
$this->ci =& get_instance();
 }



 
/**
 * @param string $key
 * @param mixed $value
 */
 
public function set$key$value )
 {
 
$this->data[$key] = $value;
 }


 
/**
 * @param string $layout layout name
 * @param string $view view name
 * @param array $data data array for templates
 */
 
public function load$layout ''$view ''$data = array() )
 {
 
// Merging ensures taht the default data like title will be rewritten or stayed on default values.
 
$this->data array_merge$this->data$data );

 
// Sets the view variable in layout file.
 
$this->data['view'] = $this->ci->load->view$view$this->datatrue );

 
$this->ci->load->view$layout$this->data ); 
}



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