|Last Updated||Ratings||Unique User Downloads||Download Rankings|
|2006-02-07 (10 years ago)||Not enough user ratings||Total: 2,420||All time: 1,540 This week: 828|
|blocktemplate 1.0||GNU General Publi...||Templates|
This class implements a template engine based on the concept of blocks.
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
|Version Control||Unique User Downloads||Download Rankings|