Welcome Guest, Not a member yet? Register   Sign In
Template/Layout Library
#1

[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.
#2

[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>
&lt;html&gt;
&lt;head&gt;
&lt;meta charset="UTF-8" /&gt;

&lt;title&gt;&lt;?php echo $title; ?&gt;&lt;/title&gt;

&lt;?php echo $stylesheets; ?&gt;
&lt;/head&gt;

&lt;body&gt;
<div id="container">
&lt;?php echo $content; ?&gt;
</div>

&lt;?php echo $javascripts; ?&gt;
&lt;/body&gt;
&lt;/html&gt;

------------------------------------

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...
#3

[eluser]zackhovatter[/eluser]
Did you try $this->load->library('template'); ?
#4

[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




Theme © iAndrew 2016 - Forum software by © MyBB