PHP Classes

Block template: Template engine based in the concept of blocks

Recommend this page to a friend!
     
  Info   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 51%Total: 2,458 All time: 1,578 This week: 68Up
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 is available for providing paid consulting. Contact Jonathan Gotti .
Classes: 13 packages by
Country: France France
Age: 48
All time rank: 724 in France France
Week rank: 164 Down7 in France France Down
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 (5)  
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

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:2,458
This week:0
All time:1,578
This week:68Up
 User Ratings  
 
 All time
Utility:68%StarStarStarStar
Consistency:56%StarStarStar
Documentation:56%StarStarStar
Examples:56%StarStarStar
Tests:-
Videos:-
Overall:51%StarStarStar
Rank:2562