-
Notifications
You must be signed in to change notification settings - Fork 0
Home
dependencies
- anonymous functions
- array dereferencing
Uses the DIRECTORY/CONTROLLER/METHOD to group your views
SAMPLE:
With Directory
URL 1: example.com/dir/class/method
Template::load()
will find the pages on views/pages/dir/class/method.php
With no directory
URL 2: example.com/class/method
Template::load()
will find the pages on views/pages/class/method.php
- Add This file on the libraries folder
- Load the file using $this->load->libraries('template') or add on the autoload.php config
- Setup the
template_path
and thepages_path
(must be inside the views folder) - You are good to go!!
load our main template
Template::set('template','temp_main')
//minify data upon output
//removes whitespaces and tab indents
//default TRUE
Template::set('minify',true);
compress data upon output gzip deflate default TRUE Template::set('compress',true);
_add ^ on the beginning so that Template will ignore and not add a base URL
Template::set('css',[
'test/test/test',
'^http://www.google.com', #add ^ on the first part for external links
'^http://www.testing.com?getid=12?4434', #add ^ on the first part for external links
'^cxds.com', #add ^ on the first part for external links
'^path/test/123', #add ^ on the first part for external links
]);`
add ^ on the beginning so that Template will ignore and not add a base URL
Template::set('javascript',[
'test/test/test',
'^http://www.google.com', #add ^ on the first part for external links
'^http://www.testing.com?getid=12?4434', #add ^ on the first part for external links
'^cxds.com', #add ^ on the first part for external links
'^path/test/123', #add ^ on the first part for external links
]);
Template::set('javascript',['test/test/test'],'head');
Template::set('partials',[
'spam_page' => 'foo/bar/spam',
'eggs_page' => 'foo/bar/eggs',
]);
automatically sends the data to the partials also
Template::set('data',[
'data1' => 'value data 1',
'data2' => 'value data 2',
'data3' => 'value data 3',
'data4' => ['eggs','orange','apples'],
]);
will look for the VIEWS/DIR/CLASS/METHOD.php or VIEWS/CLASS/METHOD.php
Template::load();
mANUAL LOAD A SPECIFIC FILE
Template::load('pages/for/not/tony');
Variables to use on the Template Page:
-
Load Javascript on the header = $TEMPLATE_JS_HEAD
-
Anonymous functions to access the partials data = $TEMPLATE_PARTIALS('nonexistent',['name'=>'Jane Doe']);
-
Loads the Body of the page = $TEMPLATE_CONTENT
-
Loads the Footer javascript files = $TEMPLATE_JS_FOOT
-
Loads the CSS files = $TEMPLATE_CSS
Template::redirect('path/to/redirect','Message to be saved','key');
Automatically available in views data as a string
with variable name $_FLASHDATA_key
Template::redirect('path/to/redirect',array('test','tost'),'keyofFlash');
Automatically available in views data as an array
with variable name $_FLASHDATA_keyofFlash
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<?php echo $_TEMPLATE_CSS_; ?>
<?php echo $_TEMPLATE_JS_HEAD_; ?>
</head>
<body>
<section>
<?php
//this partial is not initialized
echo $_TEMPLATE_PARTIALS_('nonexistent',['name'=>'Jane Doe']);
?>
</section>
<div>
<?php echo $_TEMPLATE_CONTENT_; ?>
<?php echo $_TEMPLATE_PARTIALS_('spam_page',['name'=>'John Doe']); ?>
</div>
<?php echo $_TEMPLATE_JS_FOOT_; ?>
</body>