PHP Classes

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 (11 years ago) RSS 2.0 feedStarStarStar 54%Total: 2,426 This week: 1All time: 1,546 This week: 704Up
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.

Name: Jonathan Gotti is available for providing paid consulting. Contact Jonathan Gotti .
Classes: 13 packages by
Country: France France
Age: 40
All time rank: 714 in France France
Week rank: 377 Down14 in France France Down
Innovation award
Innovation award
Nominee: 4x

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:
 <div id='menu'>@=menu/=@</div>
 <div id='content'>

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');

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  
This week:1
All time:1,546
This week:704Up
 User Ratings  
 All time