ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
HTML_Template_IT Namespace Reference

Integrated Template - IT. More...

Detailed Description

Integrated Template - IT.

Integrated Template Extension - ITX.

IT[X] Error class.

Well there's not much to say about it. I needed a template class that supports a single template file with multiple (nested) blocks inside and a simple block API.

The Isotemplate API is somewhat tricky for a beginner although it is the best one you can build. template::parse() [phplib template = Isotemplate] requests you to name a source and a target where the current block gets parsed into. Source and target can be block names or even handler names. This API gives you a maximum of fexibility but you always have to know what you do which is quite unusual for php skripter like me.

I noticed that I do not any control on which block gets parsed into which one. If all blocks are within one file, the script knows how they are nested and in which way you have to parse them. IT knows that inner1 is a child of block2, there's no need to tell him about this.

global

(hidden and automatically added)

block1
block2
inner1 inner2

To add content to block1 you simply type: $tpl->setCurrentBlock("block1"); and repeat this as often as needed: $tpl->setVariable(...); $tpl->parseCurrentBlock();

To add content to block2 you would type something like: $tpl->setCurrentBlock("inner1"); $tpl->setVariable(...); $tpl->parseCurrentBlock();

$tpl->setVariable(...); $tpl->parseCurrentBlock();

$tpl->parse("block1");

This will result in one repition of block1 which contains two repitions of inner1. inner2 will be removed if $removeEmptyBlock is set to true which is the default.

Usage: $tpl = new HTML_Template_IT( [string filerootdir] );

// load a template or set it with setTemplate() $tpl->loadTemplatefile( string filename [, boolean removeUnknownVariables, boolean removeEmptyBlocks] )

// set "global" Variables meaning variables not beeing within a (inner) block $tpl->setVariable( string variablename, mixed value );

// like with the Isotemplates there's a second way to use setVariable() $tpl->setVariable( array ( string varname => mixed value ) );

// Let's use any block, even a deeply nested one $tpl->setCurrentBlock( string blockname );

// repeat this as often as you need it. $tpl->setVariable( array ( string varname => mixed value ) ); $tpl->parseCurrentBlock();

// get the parsed template or print it: $tpl->show() $tpl->get();

Author
Ulf Wendel uw@ne.nosp@m.tuse.nosp@m..de
Version
Id:
IT.php,v 1.20 2006/08/17 15:47:22 dsp Exp

public

With this class you get the full power of the phplib template class. You may have one file with blocks in it but you have as well one main file and multiple files one for each block. This is quite usefull when you have user configurable websites. Using blocks not in the main template allows you to modify some parts of your layout easily.

Note that you can replace an existing block and add new blocks at runtime. Adding new blocks means changing a variable placeholder to a block.

Author
Ulf Wendel uw@ne.nosp@m.tuse.nosp@m..de public
Version
Id:
ITX.php,v 1.16 2006/08/17 15:47:22 dsp Exp