Welcome Guest, Not a member yet? Register   Sign In
Advanced Template 0.5
#1

[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>

&lt;?php echo $template_contents; ?&gt;

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

[eluser]ray73864[/eluser]
php4 or php5?
#3

[eluser]Colin Williams[/eluser]
Cool. I like some of the ways you allow for deep embedding. The more template libs, the better
#4

[eluser]Moon 111[/eluser]
Here is the PHP 4 file:




Theme © iAndrew 2016 - Forum software by © MyBB