[eluser]Moon 111[/eluser]
Advanced Template is a powerful templating system that allows a simple solution to common problems. It allows you to create nested views so that you can mix and match features.
PHP 4?
The PHP 4 version is attached a few posts down.
Example:
Let's start off with a basic example: a template and a view.
Here's the code to do the loading:
Code:
$template = new AdvancedTemplate('main_template'); // Load the template from the view 'main_template.php'
$template->add('home_view', 'template_contents'); // Load a view to be displayed inside the template as the variable $template_contents
$template->display();
main_template.php
Code:
<p>This is the main template file, and the inserted contents are displayed below:</p>
<?php echo $template_contents; ?>
home_view.php
Code:
<p>This is the text for the homepage!</p>
You can also have nested views (which can be infinitely nested):
Code:
$template = new AdvancedTemplate('main_template'); // Load the template from the view 'main_template.php'
$template->add('home_view', 'template_contents'); // Load a view to be displayed inside the template as the variable $template_contents
$template->template_contents->add('nested_view', 'template_inner_contents'); // This will be load inside 'home_view.php' as $template_inner_contents
$template->display();
Setup:
Unzip and move 'advancedtemplate_helper.php' into your 'application/helpers' directory. Change 'config/autoload' so that it autoloads the helper 'advancedtemplate'.
Code:
$autoload['helper'] = array('advancedtemplate');
And that's it! You can now run it!
I hope you enjoy it, and if you need any help or find any bugs, just post.
P.S. Sorry about the bad examples.
P.S.S. The zip is attached.