The 5 TinyButStrong Golden Rules. Discover them here.
2006-10-19
Fix for the ADO database plug-in. Bug when a dabase error should display. Download the fix here.
2006-10-10
TBS version 3.2.0 RC 2 available at the download page.
2006-08-24
Plug-in Html version 1.0.4. It fixes a bug about a blank item added at the end of an option list. Download it here.
2006-08-07
Plug-in Html version 1.0.3. It fixes a bug with value not found, optimize selection and add a new parameter addmissing. Download it here.
2006-07-25
New plug-in Aggregate available. This plug-in provides aggregate calculations when a block is merged.
More details here.
2006-06-25
TBS version 3.1.1 available. Download it here. One bug fixed about parameter mtype=*m
-> See the change log.
2006-06-16
Plug-in ByPage version 1.0.3. It fixes a bug when you display the first record of the first page with data which is not a PHP array (like SQL). This update is given with the standard TBS distribution. Download it here.
2006-06-13
New plug-in PHP sent by Jéméry. This plug-in enables you to merge block or subblocks with data retrieved by a PHP function or expression. Download it here.
2006-06-13
tbsOOo version 0.7.9 available. 2 bug fixed and a new method that helps to insert images. Download it here.
2006-06-13
Plug-in Excel version 1.0.2 available. 1 bug fixed. Download it here.
2006-06-13
TBS version 3.1.0 available. Download it here. 2 new features and 6 bugs fixed. This version needs two plug-in upgrades provided with the zip file.
-> See the change log.
2006-05-26
TBS version 3.0.6 available. Download it here. On bug fixed about MergBlock() used with objects.
-> See the change log.
2006-05-22
TBS version 3.0.5 available. Download it here. On bug fixed for PHP 5 only, it is about parameter 'frm' for a date format.
-> See the change log.
If you'd like to receive a tiny flash news-letter when there is a fresh new TinyButStrong release, then you can subscribe to the TinyLetter.
Mailing List
The existing mailing list is just to talk about the next version of TBS (wanted features or plug-ins, comments, beta, concepts, internal techniques, ...).
Here are some golden rules for TBS Template Engine. If you know them it will be more easy to build and understand your first TBS templates.
(1)
When you call a method, TinyButStrong immediately applies changes in property $TBS->Source.
Some other template engines (like Smarty) work by preassigning variables, and the merging is processed in one shot at the end.
TinyButStrong doesn't work this way. As soon as you're calling a method, then the effects are immediately applied into property $TBS->source.
For example, just after $TBS->LoadTemplate(...) is called, the property $TBS->Source already contains the wanted template having all [onload] tags processed.
Also, when you call $TBS->MergeBlock('b1',...) then $TBS->Source contains the result having block "b1" merged. All [b1] tags have so been replaced and no longer exist.
Knowing this, you can understand that the order of which you are merging blocks can affect the result.
In the example below, merging blocks "gender" and "vip" will not produce the same result has "vip" and "gender". (see golden rule #4 for more details)
[vip.name;block=tr]
Gender:
(2)
[var] fields are merged when $TBS->Show() is called. Except for parametersfile , script , subtpl , if , then , else , when.
Special parameters listed above quite always need to contain expressions. That's why TBS try to merge [var] fields in those parameters when a tag is merged. But all other [var] fields are merged only when method Show() is called.
Example:
The following tag won't display correctly : [b1.date;frm=[var.format]]
To workaround this behavior, you have two solutions:
1)
Call the method $TBS->MergeField('var');
This will force to merge [var] fields immediately.
2)
Since TBS version 3.2.0 you can define var fields which are explicitely merged when the template is loaded. Example to merge $x : [onload.x].
(3)
Block parameters are taken into account only if parameter "block" is also defined.
TinyButStrong has some block parameters and some field parameters which are all different.
Examples:
- if / then / else are field parameters, and when / default are block parameters.
- magnet / mtype are field parameters, and bmagnet is a block parameter.
Whether you are using the normal syntax or the simplified syntax, a tag is recognized has a block tag only if it has the parameter "block." If it hasn't such a parameter, then any other block parameters are simply ignored by TBS and you won't have any error message for that because TBS allows any extra parameters.
Examples of bad and good:
Bad
Good
[b1.col1;bmagnet=div]
[b1.col1;magnet=div]
[b2;block=tr;frm='yyyy-mm-dd']
[b2;block=tr]
[onload;when [var.x]=1]
[onload;block=tr;when [var.x]=1]
[var.x;when [var.x]=1;then 'one']
[var.x;if [var.x]=1;then 'one']
(4)
Contents placed between the sections of a same block are always deleted.
In the example below, the block named "b1" has two sections (a yellow one and a blue one). An orange row is placed between those two sections. But when the block "b1" is merged with $TBS->MergeBlock('b1',...) then the orange row will be completely deleted and will never be displayed. TinyButStrong does not keep this zone simply because there is no logical way to process it. When you define the sections of a same block, there should not be any contents between them.
[b1.id;block=tr]
[b1.id;block=tr]
This behavior also explains why you're loosing the line breaks placed between <tr> when your template contains "block=tr". The line breaks between <tr> are deleted, all <tr> sections of the block are collapsed. If this is a problem for you, you can try the definition "block=tr+_" (see the manual to know more).
(5)
During Subtemplate Mode, all outputs are buffered and not displayed.
Parameters "script" and "file" can make TBS to work in a subtemplate mode. In this subtemplate mode, any normal output is stored into a buffer (this includes PHP error messages). When TBS get out of the subtemplate mode, then the buffered data is placed into the template.
Thus if for some reasons a PHP fatal error occurs and stops the running script, then no buffered data is prompted and all what you'll see is a blank page. If you met such a problem, we suggest that you debug your subscript in a normal mode.
If a PHP error occurs but does not stops the running script, then PHP error message will be inserted inside the main template.
-> You can also perform a search in the forum for more aswers to your problem.
How to change markers '[' and ']' to '{' and '}' or something else ?
Field and block markers have been set to '[' and ']' only for optimisation consideration.
'{' and '}' are common in Javascript code and Style definitions, but '[' and ']' are more rare.
TBS >= 2.02
Markers can have several characters.
$TBS = new clsTinyButStrong('{{,}}');
TBS 2.00 and 2.01
Markers must have only one character.
$TBS = new clsTinyButStrong('{}');
TBS 1.x (>= 1.60)
Markers must have only one character.
$GLOBALS['tbs_ChrOpen'] = '{' ; // to set after include_once('tbs_class.php')
$GLOBALS['tbs_ChrClose'] = '}' ;
TBS < 1.60
Markers cannot be changed.
How to load a template from string instead of a file ?
$TBS->Source = $my_string;
To process [onload] tags if any, with TBS >= 3.0
$TBS->MergeField('onload');
To process [onload] tags if any, with TBS < 3.0
$TBS->MergeSpecial('onload');
How to limit the usage of global variables in the template ?
Limit the hallowed global variables by a prefix:
The second argument of the TinyButStrong instantiation enables you to define a prefix for variable limitation in the template.
Example:
$TBS = new clsTinyButStrong('','pref_');
Other Var fields will produce a TBS error when the template is processed.
How to
save the merge in a string instead of display it direcly ?
Example:
$TBS->Render = TBS_NOTHING; // No exit, no output
$TBS->Show() // Merges Var fields and [onshow] fields
$result =
$TBS->Source // Get the current result
How to make a condition for parameter if/when using operators like AND, OR ?
Parameters 'if' and 'when' don't support logical operators, but only comparaisons bewteen two strings.
Operator AND can be replaced by a string concatenation. For example:
[onload;if '[var.x1]-[var.x2]'='a-b';then ...]
This condition is the same as: ([var.x1]=='a') AND ([var.x2]=='b')
But for OR usage, and also for more complicated expressions, you will need to use a custom function to performe the check. Example:
[onload;onformat=f_mycheck]
PHP:
function f_mycheck($FldName,&$CurrVal) {
global $x1, $x2;
if (($x1=='a') OR ($x2=='b')) then {
$CurrVal = 'ok';
} else {
$CurrVal = 'not ok';
}
}
When can I embed Var fields into other TBS fields ?
Var fields are always examined into parameters 'file', 'script', 'when', 'if', and since TBS version 2.02: 'then', 'else' and 'subtpl'. TBS fields are not examined in others paremeters. So if you use embedded Var fields in other paremeters, they won't be merged in the same time as the embeding field.
When can I use keyword [val] ?
Keyword [val] is supported in parameters 'file', 'script', 'if', 'then', 'else' and 'subtpl'. In other parameters this keywords is considered as a common string.
Keyword [val] is sensitive to the TBS tags markers. For example, if you set the TBS markers to '{' and '}', then the keyword becomes {val}.
How to have a headergrp containg sections of the same block ?
Since TBS version 2.02, there is a new parameter 'parentgrp' that enables you to display a header section that can contain sub-sections of the same block. This is the only case when a TBS section can embed sections of the same block.
Problems
Why '[' chars are converted into Html code '['
Since version 1.64, TBS has a Protection System which is enabled by default for each field. This protection consist in replacing all characters '[' with its Html equivalent '[' for any merged data coming from outside the template (Php variables, MySQL,...). You can deactivate the Protection System for any TBS fields using parameter 'protect=no'.
See the manual for more details.
All TBS fields are ignored in my subtemplate
With TBS version < 2.02, the Protection System stay activated for parameter 'script'. So if you use this parameter to insert something containing TBS fields, then this fields are disabled by replacement of characters '[' with '['
To by-pass this problem, you just have to set parameter 'protect=no' in the TBS tag, or to us TBS version >= 2.02.
Example: [onload;script=subcode.php;getob;protect=no]
The MySQL example page doesn't work localy
This example provided with the TBS Example Set needs to have a specific MySQL table and to connect to it. This table is available at this web site but not on your computer. The error message return by PHP is: Fatal error: Failed opening required '/cnx_mysql.php' (include_path='.;c:\php\includes') in [...]\tbs_us_examples_datamysql.php on line xx
I have the error TinyButStrong error: the cache file'...' can not be saved
This error message occurs when PHP raise an error when attempting to save the cache file on the server.
Most of the time, this is because there is no 'write' permission on the directory. Try to chnage the Unix permisson
Then you should probably change the Unix permission of the directory on the server where you're trying to save the cache file.
My subtemplate is included at the beginning of the template.
This can happen if you used the parameter 'script' instead of parameter 'file'.
The nodata section is not displayed when data is empty.
First check that you 'nodata' section is not embedded into another section of the block.
If you're merging data stored into an array, then an empty data should bee an empty array ( like array() ) ; values null or false are not considered an empty data. They simply cannod be merged.
Example of what you can do to be sure that data is not the false or the null value:
$data = ...
if ($data===false) $data = array();
$TBS->MergeBlock('blk',$data);
Some block parameters (like 'ondata', 'parentgrp',...) seem to be ignored
They are two cases when a block parameter seems to be ignored by TBS. The first one in when the block parameter is not placed in the TBS tag that contains the block definition. That is TBS tag
with parameter 'block=...'. The second case is when you have too much parameter 'block=...' inside a section. In such a case, only the first parameter 'block=... ' is taken in acount ; following block definition are ignored (note taht with explicit syntax, following tag with 'block=end' is accepeted).
Here are some examples :
* <div>[blk1.firstname;block=div] ... [blk1.subname;ondata=my_function]</div> Bad : parameter 'ondata' is ignored because there is no block definition ('block=...') in its TBS tag.
* <div>[blk1.firstname;block=div] ... [blk1.subname;block=div;ondata=my_function]</div> Bad : parameter 'ondata' is ignored because a previous block definition ('block=div') has been taking in acount. Don't forget that only one parameter 'block=' is enougth for each section of a block (two with explicit syntax).
* <div>[blk1.firstname;block=div;ondata=my_function] ... [blk1.subname]</div> Good : Block parameters are placed together.
Some [onload] blocks are never displayed despite the 'when' statement
A usual mistake is when you put TBS a field linked to a block inside the conditional statement of an [onload] tag. Remember that an [onload] tag is automatically processed as soon as you call the LoadTemplate() method. Therefore, no TBS field of block is merged yet because no MergeBlock() method has been called before.
Example :
* <div>[onload;block=div;when [blk1.colmun]=3] ... </div> Bad : The TBS fields [blk1.colmun] is not yet merged before calling LoadTemplate().
TBS is just checking is string '[blk1.colmun]' is equal to string '3'. Which is always false.
* <div>[onshow;block=div;when [blk1.colmun]=3] ... </div> Good : TBS field [blk1.colmun] can be merged before calling Show().
The merge is too slow .
TinyButStrong is a Template Engine which has good merging performance. Just a bit faster that Smarty or other without template compilation. Like for any Template Engine, the speed of your merge depends a lot on your template's structure. Here are some advices for optimizing your templates.
Don't multiply automatic fields [onshow]. It means that you'd better not put such TBS fields inside some sections of your template that will be merged with data. Otherwise, the number of this fields will be multiplied before to be processed ([onshow] tags are processed when Show() method is called). This can slow down your merging very much.
* You can often by-pass this problem by replacing [onshow] fields with [onload] fields. [onload] tags are processed just when LoadTemplate() is called. That is inevitably before any block merging. So you maybe have to prepare Php variables used for the conditional statement before this method is called.
* Please also notice that you can use conditional sections of block instead of [onshow] blocks. Conditional sections of block are normal sections with a parameter 'when'. Such sections are faster than [onshow] blocks.
For the same reason, don't multiply Var fields or other TBS fields that could be evaluated only once before a block is merged.
* You can force Var fields to be merged when you need using MergeSpecial() method.
* You can also force custom fields to be merged when you need using MergeField() method.
Use parameter 'selected' with parsimony (not too much). This parameter is quite smart but it needs Html analyse processes. Such processes cost certain execution time. This is not sensible if they are not numerous, but they can slow down the merge when they are much.
* If you have numerous checkboxes/radio/lists to select, then you can by-pass this problem by setting them using Javascript function on the OnLoad attribute of the <body> tag. Another way is to prepare one or several variables in the Php side that will add the 'checked' attributes in the tags when needed.
* Please also notice that the more your <form> section is big, the more Html analyse processes cost time. Think also that you can limit this section using parameter 'selbounds'.
When your template has many complex dynamic parts, it is better to migrate the conditional statements from the Html side to the Php side.
* You can use a custom function with parameters 'onformat' and 'ondata' which is often evaluated faster than if / then / else expressions in TBS fields.
* You can retrieve data to merge in an array, sort them, filter them, calculate some new columns in the Php side. Then merge such prepared array with a simple block.
Change Log
Version
Date
Fixes / new features
3.3.0
2008-02-29
New feature:
LoadTemplate('',$charset) set the charset without changing the current template.
This enables you, for example, to load a template from a string and then set the relevant chartset.
New plug-in event: OnMergeGroup.
It occurs when a header, a footer or a splitter is merged.
Parameter ope=nif:xxx replaces the value with null when it's equale to xxx.
It's a shortcut for [val]='xxx';then '';.
Parameter ope=minv makes parameter magnet work properly but turns the final value to be null.
This i a way to make invisible fields which can manage magnets stuffs.
Enhancements:
Paremeters headergrp, parentgrp and footergrp work for any kind of data source (array, object, ...)
and also with sub items. You can even use the virtual columns # and $.
Example: [blk;block=tr;headergrp=#] or [blk;block=tr;headergrp=ident.name]
Fields in the conditional clause of a section are also cached.
Templates and subtemplates are also searched in include_path.
Custom functions for LoadTemplate support a new argument to process newline characters.
MergeField('onload') also merges variable fields such as [onload.x].
MergeBlock('blk','cond') also merges var fields such as [blk.x] and [blk;file=...] just like [onload] and [onshow] do.
The code source has no more plublic functions.
Fixed bugs:
Wrong merging when a block is using parameter "p1" and having a field outside the block. See related topic
Now there is a TBS error message when [onload;block=...] doesn't found the block which is defined.
3.2.0
2006-11-27
New feature: Onload [var] fields.
Now a field like [onload.x] can display a PHP variable $x as soon as the template is loaded. It is very useful for optimization.
New feature: special var field [var..cst.*]
Display a PHP constant.
New feature: special var field [var..tbs_info]
Display some information about TBS version, PHP version and installed plug-ins.
New feature: enhancement for parameter ope.
Parameter ope can have several operations. It supports real values, and two new operations : div and mul.
Example : [var.x;ope=mul:2,add:1.5]
New feature: enhancement for files.
The LoadTemplate() method, and both parameters file and script also look their file in the directory of the last opened template. It can be useful to simplify subtemplate inclusion.
New feature: new time formats.
- h for hour-24 without the leading zero,
- rr for hour-12 with the leading zero,
- r for hour-12 with the leading zero, hm becomes deprecated. You cannot use double quote (") as a string delimiter in date-time formats anymore, only simple quote (').
New feature: undocumented property ErrCount.
Incremented when a TBS error is met.
New feature: undocumented property RecheckObj.
Optimization: The class is smaller and faster than previous versions.
Enhancement: Some error messages are clearer.
Fixed bug: an extra empty line could be displayed when using parameter serial and headergrp in the same block.
Fixed bug:Warning: Missing argument 3 for tbs_misc_getfile()
This message could appear under certain circumstances.
Fixed bug: Bad eror message could be prompted when a custom function fail to open a query.
Fixed bug: Problems when another script create functions array_key_exists() and property_exists() before TBS does.
Fixed bug: An unwanted extra line could be added when parameter block=_ was used on a TBS tag placed on the very beginning of a line.
Fixed bug: HTML attribute not recognized when glued to the bottom of its tag.
Example : <input value="1"/> could be not recognized.
+
Internal change: Code optimized for block analysis.
$LocR structure modified (undocumented, this is for plug-in developers).
+
Internal change: Code optimized for custom function check.
You can now preload a custom function set associated with a keyword. (undocumented).
3.1.1
2006-06-25
Fixed bug: Bad result when using parameter magnet with mtype=*m
In TBS 3.1.0 a field using this value was always bad processed.
3.1.0
2006-06-13
New feature:block=_
Now you can define a block to be the file line on which the TBS tag is defined.
This feature recognizes Linux, Mac and Windows new-line chars. Among other things, this can be useful when you're working on text files.
It also works for extending blocks. Example : block=_+(_)+_ or block=span+_
New feature:block=tag/
By adding character / at the end of the tag's name, TBS won't retrieve the closing tag. The block will be defined on the single openning HTML tag which contains the TBS tag. This can be useful to multiply an image for example.
Fixed bug: Bad merged blocks when using a definition like block=tag+tag
TBS could make a confusion on block's limits when using a block's definition containing several tags with common names.
Fixed bug:TinyButStrong Error: item ... is neither a method nor a property in the class ...
This message could happen when a TBS field tryied to display the an object's property having a null value. Now the null value is corretly taken in acount, but because of PHP restrictions, undefined properties won't produce a TBS error anymore with PHP version lower than 5.1.0.
Fixed bug: The plug-in event Ondata started before event BeforeMergeBlock.
Now BeforeMergeBlock event always start before Ondata.
Fixed bug:Notice: Undefined offset: 0 in ... on line ...
This message could happen when you tried to merge a block that have special sections (like serial or headergrp) but no normal sections. Such blocks can now be merged without error message.
Fixed bug: Variables $CurrVal and $CurrPrm not available when using parameter script.
Those variables were mentioned in the manual but not available. Now they are.
Fixed bug: Error message: pg_fetch_array(): Unable to jump to row ...
This could happens under misterious circumpstances when using PostgreSQL and PHP 5.
Plug-in HTML and ByPage need to be upgraded to works with TBS 3.1.0
3.0.6
2006-05-26
Fixed bug: error when using MergeBlock() with objects.
3.0.5
2006-05-22
Fixed bug: date formated displays 1st jan 1970.
This could occur with PHP 5.1.0 or higher and with a value which is a timestamp. This is because since PHP 5.1.0, the function strtotime() returns false instead of -1 for a bad time value.
You have a description of the problem in the forum.
3.0.4
2006-05-15
Fixed bug: Problems with data or variables when using the TBS syntax for subitems.
Some data change could occur in some circumstances:
- [var] fields calling an object's method
- Array dynamic queries calling an object's method or property
- Parameter onformat or ondata calling an object's method or property
3.0.3
2006-05-14
Fixed bug: Error message Warning: Missing argument 1 for aftershow() in ...
This could happen when a plug-in is installed in a sub-template script (called by parameter script).
Plug-in CacheSystem has been changed too in order to feet with this fix.
3.0.2
2006-05-13
Fixed bug: Bad argument supplied to plug-in's event OnMergeField.
Fixed bug: Problems with plug-in's event AfterShow.
Now Ouput and Exit happens after event AfterShow. You can cancel them using argument $Render.
Plug-in CacheSystem has been changed too in order to feet with this fix.
+
Comments in the file tbs_plugin_syntaxes has been uptated.
Fixed bug: [var] fields embedded into a parameter 'script' were not merged.
3.0.1
2006-05-10
Fixed bug: [var] fields embedded into a parameter 'script' were not merged.
TinyButStrong is released under the LGPL (Lesser GPL version 2.1).
In summary it means that:
- it's free to use it,
- you can modify it,
- it can be used as a part of both free and not free softwares. Click here for more info on the LGPL.
Contact
For questions, help, how to, bug reports, comments... contact us.