Template/Layout Library |
[eluser]zackhovatter[/eluser]
Already posted this to the Forrst community and made a few modifications to it. Figured I'd drop it in here for some feedback. Feel free to use this anywhere without giving me any credit or having to ask me or anything like that. http://www.zackhovatter.com/code/view/co...te-library https://github.com/hovatterz/CodeIgniter...te-Library A general idea of what you can do with this: * Adding Title Segments * CSS/Javascript includes (local and external) * Meta tags * Setting template variables There's all the info. Also, since I think this is my first post: Hello CI community.
[eluser]-[/eluser]
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Template extends CI_Controller { public function __construct() { parent::__construct(); $this->template ->add_title_segment('Template') ->add_javascript('jquery.js') ->add_stylesheet('screen.js'); $this->load->library('template'); } public function index() { $this->template ->add_title_segment('Overview') ->build('template/index'); } } /* End of file template.php */ /* Location: ./application/controllers/template.php */ ------------------------------- <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title><?php echo $title; ?></title> <?php echo $stylesheets; ?> </head> <body> <div id="container"> <?php echo $content; ?> </div> <?php echo $javascripts; ?> </body> </html> ------------------------------------ http://localhost/cireactor/index.php/template and show error... ------------- A PHP Error was encountered Severity: Notice Message: Undefined property: Template::$template Filename: controllers/template.php Line Number: 9 ------------------------------- whats wrong ? can u help me... thanks...
[eluser]zackhovatter[/eluser]
Did you try $this->load->library('template'); ?
[eluser]-[/eluser]
class Template extends CI_Controller { public function __construct() { parent::__construct(); $this->template ->add_title_segment(‘Template’) ->add_javascript(‘jquery.js’) ->add_stylesheet(‘screen.js’); } public function index() { $this->template ->add_title_segment(‘Template’) ->build(‘template/index’); } } still error --------------- in root directory : _assets css js img or views directory : views _assets css js img |
Welcome Guest, Not a member yet? Register Sign In |