PHP Classes
elePHPant
Icontem

Block template: Template engine based in the concept of blocks

Recommend this page to a friend!
  Info   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2006-02-07 (10 years ago) RSS 2.0 feedStarStarStar 54%Total: 2,423 All time: 1,544 This week: 1,109Up
Version License Categories
blocktemplate 1.0GNU General Publi...Templates
Description Author

This class implements a template engine based on the concept of blocks.

The template files do not define looping logic, only variables or parameters to be replaced, to avoid using programming concepts that are not easy to understand for designers.

The class supports event driven callback functions for customizing the template engine behavior.

Picture of Jonathan Gotti
Name: Jonathan Gotti <contact>
Classes: 13 packages by
Country: France France
Innovation award
Innovation award
Nominee: 4x

Details
Block Template (BT in the rest of this document) is a template engine based on the idea that a web page is composed of some GUI blocs elements such as box and that web-designer don't even think about loop or so complicate stuff that only regards the programmer at all.

#### Template Files tree:
in order to get BT to work you must have a template directory that contains all templates. Each template is a directory inside the template directory with the name of the template.
Inside this dir you will have at least 2 files:
css.css and template.php here's what the file tree look like:
template/          <- contain all templates dir
 |_default/        <- contain template files for template default
    |_template.php <- the main 'default' template file
    |_css.css      <- the main 'default' css rules
 |_bline2/        <- contain template files for template bline2
    |_template.php <- the main 'default' template file
    |_css.css      <- the main 'default' css rules

### Template.php file:
this is the main tempalte file it have to contain some 'sections' or 'Blocs' whith some variables inside their contents here's a little sample for a body section:
@#BODY
<body>
 <h1>@=page_title/=@</h1>
 <div id='menu'>@=menu/=@</div>
 <div id='content'>
   @=content/=@
 </div>
</body>

When this piece of template will be rendered it will replace page_title and content with their needed vars. As you can see variables are includes as tag begining with '@=' and ending with '/=@' (don't forget the / at the end) or as an open-close pair of tag: @=tag=@ blabla @=/tag=@ exactly like html but with @=,=@ in place of <,>
Be aware that you MUST provide a BODY section or you will not have any content display at all!

#### css.css file:
just a classic CSS file (optional at all)

#### Quick Use Sample ####
here's a really short sample to show you how to use block template:
$page = &new block_template('test page','templatename');
$vars = array('content'=>'here goes your content','menu'=>'here your html menu code for example');
$page->output($vars);

And that's all.

You can do some really more advanced stuff with this class like support some callbacks to plug some replacement method of your own, but i've no time to document it better for now just look to the class code and play a little with it, i'm sure you will find your way. as always all modifications and feedback are welcomes

More info to come when time will come back :p
  Files folder image Files  
File Role Description
Accessible without login Plain text file btsample.php Example sample of use
Accessible without login Plain text file class-block_template.php Class main class file
Accessible without login HTML file classblock__template.html Doc. class documentation
Accessible without login Plain text file README Doc. block template concept
Accessible without login Plain text file template.php Appl. sample template file

 Version Control Unique User Downloads Download Rankings  
 0%
Total:2,423
This week:0
All time:1,544
This week:1,109Up
 User Ratings  
 
 All time
Utility:75%StarStarStarStar
Consistency:58%StarStarStar
Documentation:58%StarStarStar
Examples:58%StarStarStar
Tests:-
Videos:-
Overall:54%StarStarStar
Rank:1627