Sei sulla pagina 1di 34

13/02/12

TBS Manual

What is it for? Why use it? Examples Downloads Manual Plug-ins Other tools News Support Forum Testimonials Your sites Franais
Site: www.tinybuts trong.c om A uthors : s krol2 9 , P irjo D ate: 2 0 1 1 -1 0 -2 6
* ........................... . * * * * * * * * * * * * * *

TinyButStrong Documentation
vers ion 3 .8
* ........................... . * * * * * * * * * * * * * *

Template Engine for Pro and Beginners for PHP 5 Table of Contents: Subject Introduction Basic principles Installation Mini examples PHP side To begin create a new TBS object m e thod LoadTemplate() m e thod MergeBlock() m e thod Show() Advanced m e thod GetBlockSource() m e thod MergeField() m e thod PlugIn() prope rty Assigned prope rty NoErr prope rty Render prope rty Source prope rty TplVars Object Oriented Programming (OOP) Template side TBS fields Definition and syntax Parameters Order of processing parameters Automatic fields Special Automatic fields TBS blocks Definition and syntaxes Parameters Sections of block Automatic blocks Serial display (in columns) Subblocks Automatic subblocks Subblocks with dynamic queries Miscellaneous Subtemplates Conditional display overview Coding plug-ins Database Plug-ins Other plug-ins Summary TBS Field's parameters TBS Block's parameters Names of Special Fields and Blocks Description

for working with templates load the contents of a template from a file merge a part of the template with a data source automatic processing and display of the result returns the source of the definition of a block merge a specific field with a value execute a plug-in's action prepares information for a subsequent merging avoid error messages to alter the merge ending option returns the current contents of the result returns template variables to make TBS OOP friendly

www.tin butstrong.com/manual.php#php_mergeblock

1/34

13/02/12

TBS Manual

Introduction:
Tin ButStrong (TBS) is a PHP class useful to develop an application in a clean way, separating PHP scripts and XML/HTML/Text files. With TBS, the files are generated dynamically by merging a template with data. It is called a Template Engine. The name TBS comes from the fact that this tool contains only 8 functions and yet, it is very powerful. It allows you to merge templates with your PHP variables or your MySQL, PostgreSQL, or SQLite. TBS has been engineered so that you can develop your templates with ease using any visual editors (like Dreamweaver or FrontPage). But if you are used to designing your templates with a text editor, it is nice as well. TBS also enables you to create JavaScript dynamically. As the name of it tells, TBS is easy to use, strong and fast. It is completely ~ freeware ~ .

Basic principles:
On the HTML side (or other file type): You design a page which does not necessarily contain any PHP scripts, nor any programming. In this page you place TBS tags in the places where you want to display the dynamic data. This page is called a 'template'. There are two types of tags: the 'fields' which are used to display dynamic data items, and the 'blocks' which are used to define an area, mostly in order to display records from a data source. On the PHP side: You use an object TBS variable to manage the merge of your template with the data. At the end, TBS shows the result of the merge.

Installation:
1. 2. Copy the file tbs_class.php in a directory of your Web site. At the beginning of your PHP program, add the lines: icueoc(tscaspp) nld_ne'b_ls.h'; $B = n csi Bttog TS & e lTn uSrn;
R e m ark : if the TBS file tbs_class.php is in a diffe re nt dire ctory than your application, the n you have to pre cise the dire ctory in front of the TBS file nam e .

Explanations and technical details: TinyButStrong is a library written in PHP, it's a component to be referenced in your own PHP programs. In technical terms, TinyButStrong is a PHP 'class' ; the name of this class is clsTinyButStrong. The variable $TBS that you add at the beginning of your PHP program enables you to execute the merge of your template from your PHP application. In technical terms, the variable $TBS is an 'instance' of the clsTinyButStrong class.

Mini examples:
Example 1: Html Template <html> <body> [onshow.message] </body> </html> Php Program < ? icueoc(tscaspp) nld_ne'b_ls.h'; $B = n csi Bttog TS & e lTn uSrn; $B-LaTmlt(tmlt.t'; TS>odepae'epaehm) $esg ='el' msae Hlo; $B-So(; TS>hw) ? > Example 2: Html Template <table> <tr><td>[blk.val;block=tr]</td></tr> </table> Php Program < ? icueoc(tscaspp) nld_ne'b_ls.h'; $B = n csi Bttog TS & e lTn uSrn; $B-LaTmlt(tmlt.t'; TS>odepae'epaehm) $it=ar (X,Y,Z) ls ra ''''''; $B-Mrelc(bk,$it; TS>egBok'l' ls) $B-So(; TS>hw) ? > Result <table> <tr><td>X</td></tr> <tr><td>Y</td></tr> <tr><td>Z</td></tr> </table> Result <html> <body> Hello </body> </html>

www.tin butstrong.com/manual.php#php_mergeblock

2/34

13/02/12

TBS Manual

PHP side:
The merging of a template is done in a PHP program using an object variable declared as a clsTinyButStrong class. Example of statement: $ B = n c s i y u S r n ; TS e lTnBttog This object allows you to load a template, to handle the merging of it with data, and then to show the result. Example of PHP code: icueoc(tscaspp) nld_ne'b_ls.h'; $B = n csiyuSrn; TS & e lTnBttog $B-LaTmlt(tmlt.t' ; TS>odepae'epaehm) $B-Mrelc(cr''yq''EET*FO tcuty) TS>egBok'ty,msl,SLC RM _onr'; $B-So(; TS>hw) Here is the description of the TinyButStrong object:

create a new TBS object:


A TBS object is created as a new instance of the clsTinyButStrong class. A TBS object enables you to work with one or several templates using the object's methods and properties. Syntax to create a new TBS object: $ B = n w c s i y u S r n ( TS e lTnBttog{ igFtrfx ) n cPei Argument TagDelim Description Define the couple of delimiters for TBS tags recognized in templates. The default value is '' (empty string) which means the default TBS delimiters. That is '[' and ']'. Example: if you want to have the delimiters to be {{ and for TBS fields, then set TagDelim to the value '{{, '. Thus TBS fields will be like {{var.x instead of [var.x]. It's recommended to let the default TBS delimiters, while changing them is working well. Default TBS delimiters are [ and ] because those characters are usable quite everywhere in XML/HTML documents, and they are located faster than delimiters { / or ( / ) since they are rarer, especially in HTML. Limit the usage of automatic fields ([onload] [onshow] and [var]) in templates. TBS will display only global PHP variables prefixed with VarPrefix. Other variables will produce an error message. The default for VarPrefix value is '' (empty string) which means no limitation. Limit the usage of custom PHP functions (relative to parameters onformat and ondata) in templates. TBS will call only PHP function prefixed with FctPrefix. Other functions will produce an error message. The default value is '' (empty string) which means no limitation. This argument is supported since TBS version 3.6.0. igTgei { n aDlm , igVrrfx{ n aPei ,

VarPrefix

FctPrefix

Examples: $B1=nwcsiyuSrn; TS e lTnBttog / dfutbhvo / eal eair $B2=nwcsiyuSrn({, '; TS e lTnBttog'{ ) / TStg wl b lk {vrx isedo [a.] / B as il e ie {a. nta f vrx $B3=nwcsiyuSrn(' 'b_a_) TS e lTnBttog', tsvr'; / TSwl dslyol PPgoa vrals / B il ipa ny H lbl aibe bgnigwt 'b_a_ einn ih tsvr' $B4=nwcsiyuSrn(' ','b_c_)/ TSwl cl ol PPfnto bgnigwt TS e lTnBttog', ' tsft';/ B il al ny H ucin einn ih 'b_c_ tsft'

method LoadTemplate():
Loads a template for the merging process. The complete contents of the file is immediately stored in the Source property of the TBS object, then [onload] fields and blocks are merged. If the file is not found, then it will also be searched in the folder of the last loaded template (since TBS version 3.2.0). Syntax: $ B - L a T m l t ( TS>odepae Argument File Charset Description Local or absolute path of the file to load. This value can be null or '' (empty string) for special actions. See below for more details. Optional. Indicates the character encoding (charset) to use for conversion of special characters when data will be merged. It should be the same as the charset of the template. The default value is '' (empty string) which is equivalent to 'ISO-8859-1' (Latin 1). If your template uses a special charset, then indicate the Html value for this charset. In a Html page, the charset is placed at the beginning of the file, in the attribute 'content' of a <Meta> tag. The charsets supported by TBS are the charsets supported by the PHP function htmlentities(). For example: 'BIG5' (Chinese) or 'EUCJP' (Japanese).
www.tin butstrong.com/manual.php#php_mergeblock 3/34

igFl{ n ie,

igCast) n hre

13/02/12

TBS Manual

S S I S N I N U I S S S H TBS TBS TBS (&$ : .F , 3.0, ' 3.3.0, 3.5.0, '). TBS : . 3.3.0, F : C '

. , _ , . .

TBS

PHP,

'= (

OOP).

'. .E . :

,'

C :

fnto fSrom(Ttsrn,CnB boen { ucin _tTXl$x tig$ovr ola) / Cnetasrn it a XLtx. / ovr tig no n M et $ =hmseilhr(t8ecd(Tt) tlpcacasuf_noe$x); i (CnB){ f $ovr $ =n2r$) / Cnetaytp o ln bek x lb(x; / ovr n ye f ie ra $ =srrpae'b /' 'tx:iebek>,x; x t_elc(<r >, <etln-ra/'$) rtr $; eun x

A Y S S I F I F I E

.T TBS '' ( : 3.4.0. , C ),

'+' F : (P '+', -

: .

,[

. .

$B-Suc =$epae / la tetmlt fo asrn TS>ore tmlt; / od h epae rm tig $B-LaTmlt(ul'I5) / rnpu-n i ay admre [nod tg i ay TS>odepaenl,BG'; / u lgis f n, n egs ola] as f n .. . $B-LaTmlt('fle;/ tr tecastt n-hre TS>odepae',as) / un h hre o ocast

M
M , B S

():
TBS ( B : . '. ( . N ). , ),

T P D Y S A B

, : M SQL ; P

. SQL ; SQL :'

: it$B-Mrelc(tigBokae m e Suc{ srn Qey{ m e Qyrs) n TS>egBoksrn lcNm, i d ore, tig ur , i d rPm D N I Y V TBS '*' : '*' , . . .I .E . : :
4/34

. PHP TBS 3.0. . . .F .

.I ,

S Q Q P

I T O T O V SQL

TBS

3.7.0.

L
www.tin butstrong.com/manual.php#php_mergeblock

13/02/12

TBS Manual

T T

() ' , . TBS F '

TBS . A TBS F '

.T

, .A

E B C L I Y M Y B E Y ,

: ' TBS F ' : 1 :[ 1. : 1], [ . .F : 1, 2, , 3 2], [ M

1.

1. B

3] () , TBS B .

.I , , : $B-Mrelc(bok,lc2bok'' sl,SLC *FO MTbe) TS>egBok'lc1bok,lc3,m q''EET RM al'; .N . Name = ; 1] [ . Id ] [ . ; , TBS TBS .I

1 :

Id [ . ;

Name = ; 1] [ .

V R I E C T E T E R

$B-Mrelc(b,msl,SLC *FO MTbe) TS>egBok''' q''EET RM al'; : TBS 3.4. : , :$ .F ,

. = $B-Mrelc(bok,'' sl,SLC *FO MTbe) TS>egBok'lc1*,m q''EET RM aal'; : , TBS F '#'. I

'*'

'

.U

:[ :[ R

1.#] '$' 1.$]

. P : .

Data Source T pe A T N C C PHP A


(* ) (* ) (* ) (* ) (* ) (* )

Source T T T T T AP T T ' ' .S 3.5.0. ' ' TBS ' ' ' ' ' ' ' ' ' '

Quer A A AP A A PHP ( ) ( )

PHP A PHP I PHP I PDO Z

O A

A PHP

A PDO DB A AZ S

.S 3.7.0. DB A TBS .

TBS

A SQL A SQL A SQL

.O PDOS .O $ ->

-> ($

Q Q ,$

P (Q P ).

).

3.8.0.

M SQL

A M SQL TBS

.S 3.7.0.

www.tin butstrong.com/manual.php#php_mergeblock

5/34

13/02/12

TBS Manual

M SQL

AM S AM S

' S S

'

A SQL A SQL A SQL -

P SQL

SQL

AP AP A SQL A SQL A S

, '
.

. '.

A SQL

(* ) S

P Assigned T T E V Te t T T E Number T T N A E Q : : :

S : $B-Mrelc(b'; TS>egBok'1) : ' '

'

' TBS

. A 3.5.

' '. ( ) '#' 1, 0 Q : $B-Mrelc(b''et,Hlo h ae o?) TS>egBok'1,t ''el, o r u';

Q .

.N

S Q R T ' T T R ' . R S S

'

'.

. .T . ' ' ' ' R S ' ' ' '. ' '

'

'

$B-Mrelc(b''u'1) TS>egBok'1,nm,2; $B-Mrelc(b''u'ar (mn=2,m '>0) TS>egBok'2,nm,ra 'i'>0'a =3); $B-Mrelc(b''u'ar (mn=1,m '>0'tp=2) TS>egBok'3,nm,ra 'i'>0'a =2,se'>); Clear T A E Conditional T T S E Arra T . S ' ' E 1' ' : Q S P [ 2' 1][ PHP A A 2]...' $ $ . . ' '. I ' ', S .E . : $B-Mrelc(b''od) TS>egBok' ,cn'; TBS ' '. .T , .I : $B-Mrelc(b''la'; TS>egBok'1,cer) S ' '. .

:' '

I E

$B-Mrelc(bok''ra''asmn'; TS>egBok'lc1,ar ,d [o]) T ' 1' $ [' '] ' . : $B-Mrelc(bok''ra''as) TS>egBok'lc1,ar ,d ';

T -> I -> Y
www.tin butstrong.com/manual.php#php_mergeblock

A .

.T

6/34

13/02/12

TBS Manual

D Y E S I C E T C E 2: 1: :[ 1.$] A :

'$'

: .

.T

2).

1),

[' [' ... R

1']=> 2']=> S

1 2 . 1']=> 1']=> 1']=> ' ' , ' '

[0] => ([' [1] => ([' [2] => ([' ... R S

1-0 ; [' 1-1 ; [' 1-2 ; [' '

2']=> 2']=> 2']=> 1', '

2-0 ; ...) 2-1 ; ...) 2-2 ; ...) 2',... .

S
T S T S -M -M -D -E T R

():
. : $B-So(itRne ) TS>hw{n edr [ [ () ] ( . ( ( / : , R R 3.2.0), / / S ). () ), .S R

G
R I

S
,

():
TBS B Fle as. .

S : srn $B-GtlcSuc(tigBokae{ boenAAry{ boenDfas{ m tig TS>eBokoresrn lcNm , ola sra , ola eTg , i Rpaeih) elcWt A B A A N D T O .T PHP .T False. I : .D : .Y . False. I R W . Fle I as. .F 1. Tu. B re .I F .I , ' TBS . 3.0. ) TBS 3.05. . ; G Tu re , B S () ,

D T

O D T V

O V

= '' (

T A V False ;

:S

TBS 3.05 TBS 3.05

A A False .S TBS 3.05 A A A .

, Tr e

()

'

' TBS 3.05

():
7/34

www.tin butstrong.com/manual.php#php_mergeblock

13/02/12

TBS Manual

Replace one o e e al TBS Field i h a fi ed al e o b calling a e f nc ion. Since TBS e ion 3.0, i ' al o po ible o indica e a me hod of a cla ( ee OOP). Each TBS field ha ing he pecified ba e name ill be me ged. I i al o po ible o me ge he pecial [onload], [on ho ] and [ a ] ( ee belo ). S n a : $B-Mreil(tigBsNm,m e X{ boenFntoMd { ar Dfutr ) TS>egFedsrn aeae i d , ola ucinoe , ra ealPm A g men Ba eName X De c ip ion Ba e name of he TBS Field . Fo e ample 'acco n '. The al e o di pla (o a ing ha F nc ionMode i e o e). ep e en he name of a e f nc ion if he a g men

F nc ionMode Indica e ha he al e o di pla i calc la ed b a e f nc ion. The defa l al e i fal e. If hi a g men i e o e, hen X m be a e ing gi ing he name of he e f nc ion. Thi f nc ion m e i and ha e he n a de c ibed belo . Defa l P m Li of pa ame e o appl b defa l o he me ged field . Pa ame e ha e o be gi en a an a ocia i e PHP a a . If a pa ame e i defined in bo h a g men Defa l P m and in he field, hen he pa ame e of he field ill be aken in acco n . Thi a g men i ppo ed ince TBS e ion 3.5.0.

Me ging

i h a al e: ha e ffi e like

X can be n me ic, ing, an a a o an objec . Fo an a a o an objec , name of TBS Field m a oma ic field ([onload] and [on ho ]). E ample: $B-Mreil(acut,ra(i'>5'ae='o') TS>egFed'con'ary'd=5,nm'>Bb);
In hi e am ple , he fie ld [acco n .id] and [acco n .nam e ] ill be m e ge d.

Me ging

iha

e f nc ion:

TBS call hi f nc ion fo each field fo nd in he empla e. Thi f nc ion m ha e he follo ing n a : fnto ftue(Sbae[ $rLt){. ucin c_sr$unm , Pms] .. When he f nc ion i called, i a g men $S bname ha fo al e he ffi of he field' name (e ample: fo a field named 'ml. i le', $S bname ill ha e he al e ' i le'). And he op ional a g men $P mL con ain an a ocia i e a a i h he field' pa ame e . The f nc ion m e n he al e o be me ged. E ample: $B-Mreil(m''_utlnug'tu) TS>egFed'l,mmliagae,re; .. . fnto mmliagae$unm){ ucin _utlnug(Sbae goa $agi; lbl ln_d $s=mslqey"EETtx_ln_dA ttFO tlnug WEEky'Sbae) r yq_ur(SLC et$agi S x RM _agae HR e=$unm"; $e =mslfthary$s; rc yq_ec_ra(r) rtr $e[tt]; eun rc'x'
In hi e am ple , a fie ld ch a [m l. i le ] ill be m e ge d i h he al e e ne d b m _m l ilang age (' i le ').

Me ge a

oma ic field and block :

Yo can e he me hod Me geField() in o de o fo ce he me ge of he a oma ic field and block ([onload] and [on ho ]). B in hi ca e, onl he fi a g men ho ld be indica ed. E ample: $ B - M r e i l ( v r ) TS>egFed'a'; Ve ioning: he me ge of pecial field i ppo ed ince TBS e ion 3.0. I eplace he old me hod Me geSpecial() hich i no ppo ed an mo e.

Me hod Pl gIn():
Enable o o call a TBS pl g-in' command, o o in all a TBS pl g-in.

S n a : m e $B-PuI(ie ag,m e ag,.. i d TS>lgnm d r1 i d r2 .) Remind: in o de o ha e o TBS pl g-in o king, i PHP c ip m be incl ded in o E ample: i c u e o c ( t s p u i _ x . h ' ; nld_ne'b_lgnxxpp) And a lo, e e TBS pl g-in ho ld ha e a ke a e plained a Pl g-in . Calling a pl g-in's command: U e he pl g-in' ke a he main a g men . Ne E ample: $B-PuI(B_X,ag,r2; TS>lgnTSXX$r1ag)
In hi e am ple , he pl g-in ide n ifie d b he k e

applica ion befo e.

a g men

a e fo

he called pl g-in' p

po e.

TBS_XXX i

calle d.

Rema k:

hen o

call a pl g-in' command fo

he fi

ime hi pl g-in i a

oma icall in

alled on he TBS
8/34

www.tin butstrong.com/manual.php#php_mergeblock

13/02/12

TBS Manual

($TBS). In alling a pl g-in: A .F , E : , TBS_INSTALL

- '

$B-PuI(B_NTL,B_X) TS>lgnTSISALTSXX;
I , -

TBS_XXX

R *A *A V

: ( :

$TBS2)

TBS

$TBS

). I

. P

TBS I () ( ).

I ()

TBS

3.0.

P
E S P

:
.

: ar $B-Asge ra TS>sind A .A PHP .I D '=>' '=>' '=>' '=>' '=>0 ' ' ' ' I I I I T . : $B-Asge[b]=ar (b,2,&cti,'EETi,nm FO tbe'; TS>sind'' ra '1b' $n_d SLC d ae RM al1) .. . $B-Mrelc(b) / mrebokb adb wt teSLqe TS>egBok''; / eg lc 1 n 2 ih h Q ur TBS .I . M M B F () () .T . [ [ ] ] . . PHP .A M B () : M F ()

O ' ' ' ' '

: $B-Asge[b]=ar (b,2,&cti,'EETi,nm FO tbe' 'uo='nod) TS>sind'' ra '1b' $n_d SLC d ae RM al1, at'>ola';

: $B-Asge[f' =ar (f' $aa ' p'>mreil'; TS>sind'1] ra '1, dt, t e='egfed) .. . $B-Mreil(f';/ mrefedf wtttear $aa TS>egFed'1) / eg il 1 ih h ra dt

N -T -A L -Y

: .Y , $TBS->M ' () .

, B (' ') '=>' ' .

='

', $TBS->M B , , .T

(' ', '

'). PHP 4

.I

TBS

3.5.

N E :
E T B S E C S E : boen$B-NEr ola TS>or : $B-NEr=tu;/ n mr errmsaei dsl e TS>or re / o oe ro esg s ipa d
9/34

TBS

.D ..

]. F

.T .

www.tin butstrong.com/manual.php#php_mergeblock

13/02/12

TBS Manual

P -F -F

N E

: .I TBS O O TBS T B .U S $B-NErtu TS>or=re . 3.0. TBS . [

.T .F , .. O _ O ]

TBS

V -P -S

: N E [

..

TBS

3.5.0.

R
I T T S T C R

:
. (TBS_OUTPUT + TBS_EXIT). .

: it$B-Rne n TS>edr S D . . TBS P . E . () .

TBS_NOTHING I TBS_OUTPUT TBS_EXIT I I

S
T W S N -T T -T I T B

:
S ( M B .I () / . ), S

: srn $B-Suc tig TS>ore : L ,S S T () () [ ] P , S [ . ] .

T :

().

$B-Suc =$ _epae TS>ore m tmlt; $B-LaTmlt(ul;/ rnpu-n i a ,admre [nod tg i a TS>odepaenl) / u lgis f n n egs ola] as f n I , :

$B-So(B_OHN) / triaetemrigwtotlaigtesrp nrt dsl tersl TS>hwTSNTIG; / emnt h egn ihu evn h cit o o ipa h eut $eut=$B-Suc; rsl TS>ore

T V
C S Y . E
T

:
.

: ar $B-Tlas ra TS>pVr T V : ; L T .A ()

TBS

='1.12.27';

PHP

='2004-10-26']

R -P -Y

$B-Tlas'epaevrin]='.22' TS>pVr[tmlt_eso' 11.7; $B-Tlas'epaedt' ='041-6; TS>pVr[tmlt_ae] 20-02' :

(OOP):
10/34

www.tin butstrong.com/manual.php#php_mergeblock

13/02/12

TBS Manual

TinyButStrong integrate a technique to call methods or properties of objects that you've coded at the PHP side. Calling methods of a class Feature Parameter ondata Parameter onformat Method LoadTemplate() Method MergeField() ithout created object: Example [blk1.column1;block=tr;ondata=MyClass.methA] [blk1.column2;onformat=MyClass.methB] $TBS->LoadTemplate('mytemplate.htm','=MyClass.methC'); $TBS->MergeField('myfield','MyClass.methD',true);

The following TBS features support the call to the methods of a class without created object.

Remark: Methods call using this technique must respect the function syntax expected by the feature (see the description of the corresponding feature). Calling created objects: TBS has an ObjectRef property that is set to fal e by default, and that you can use to reference your objects already created. You can reference an object directly on the ObjectRef property, or you can reference some using PHP arrays. Example: $B-OjcRf= $ Ojc1 TS>bete & M bet; You can use an array if you have several objects reference: $B-OjcRf'tm' = $ Ojc1 TS>bete[ie1] & M bet; $B-OjcRf'tm' = $ Ojc2 TS>bete[ie2] & M bet; You can use as many levels as you wish: $B-OjcRf'tm'[a]0 = $ Ojc4 TS>bete[ie3]''[] & M bet; Remarks: * Think to use the assignment by reference using "=&" instead of "=", otherwise a copy of the object will be created. * Since an object is referenced under ObjectRef, its sub objects will also be accessible by the TBS syntax. Using ObjectRef in automatic fields: Use the symbol '~' to call what is referenced under ObjectRef. For example (valid for both [onload], [onshow] and [var]): The field [onshow.~propA] [onshow.~propA.propB] [onshow.~item2.propA] [onshow.~item2.methX] [onshow.~item2.methY(a,b)] Will call $B-OjcRf>rp TS>bete-poA $B-OjcRf>rp-poB TS>bete-poA>rp $B-OjcRf'tm'-poA TS>bete[ie2]>rp $B-OjcRf'tm'-mtX) TS>bete[ie2]>eh( $B-OjcRf'tm'-mtY'''' TS>bete[ie2]>eh(a,b)

Remark: TBS proceeds to a coherence control, it will determine itself whether your automatic field definition is calling to ObjectRef via an array's item, an object's property or an object's method. Anyway, take care that your automatic field must call a value at the end, not an object. Using ObjectRef in other TBS features: The following TBS features support the call to the methods of objects referenced under ObjectRef. Feature Parameter ondata Parameter onformat Method LoadTemplate() Method MergeField() Method MergeBlock() Example [blk1.column1;block=tr;ondata=~item1.methA] [blk1.column2;onformat=~item1.methB] $TBS->LoadTemplate('mytemplate.htm','=~item1.methC'); $TBS->MergeField('myfield','~item1.methD',true); $TBS->MergeBlock('blk1','~mydb','SELECT * FROM t_table');

Remark: Methods call using this technique must respect the function syntax expected by the feature (see the description of the corresponding feature).

Template side:
You design your template by placing TBS tags in the places where data items should appear. There are two types of TBS tags: Field and Block . A TBS Field is a TBS tag which has to be replaced by a single data item. It is possible to specify a display format and also other parameters. The syntax for TBS Fields is described below. A TBS Block is an area which has to be repeated. It is defined using one or two TBS fields. Most often, it is the row of an HTML table. The syntax for TBS Blocks is described below.

TBS Fields:
www.tin butstrong.com/manual.php#php_mergeblock 11/34

13/02/12

TBS Manual

A TBS field is a TBS tag which has to be replaced by a single data item. A TBS fields must have a name to identify it (which does not have to be unique) and can have parameters to modify the displayed value. Syntax: TEMPLATE ... [FieldName{;param1 {;param2 {;param3 {... ] ... TEMPLATE Element FieldName param1 Description The name of the Field. Warning: names that begin with onload, onshow and var.are reserved for automatic fields. Optional. One or more parameters from the list below and separated with ';'. Some parameters can be set to a value using the equal sign '='. Example: frm=0.00 If the value contains spaces, semicolons or quotes, then you can use single quotes as delimiters. Example: frm='0 000.00' To specify a literal single quote, escape it with a second single quotes. Example: ifempty='hello that''s me' A parameter can contain embedded TBS fields, but only under special circumstances: - the embedded field is merged before the parent field, - the embedded field if a [var] field placed into a parameter file, script, if, then, else or when. In the other cases; the embedded TBS field will not be processed and will be taken as is, like text. Examples: [x;htmlconv=[var.y]] : [var.y] will not be merged and parameter "htmlconv" will have an unvalid value. [x;if [var.y]=1] : [var.y] will be correctly merged and the "if" condition will be correctly evaluated. Field' pa ame e Parameter htmlconv=val : Description Ennables you to modify the special character conversion for this TBS field only. Note that the special character conversion used by default for all TBS fields is the one defined by LoadTemplate(). It is often corresponding to an Xml/Html charset but not necessary. The value val can be one of the following keywords: yes no nobr wsp esc js url utf8 look (default value) Performe the default special character conversion, including new lines. No special character conversion. Useful to modify Xml/Html source. Let the default special character conversion, except new lines (useful for <pre> tags for example). Preserve white spaces (useful for spaces at the beginning of lines). No special character conversion and double the single quote characters ('). Convert the data item to a string that can be inserted between JavaScript text delimiters. Convert the data item to a string that can be inserted inside an URL. (supported since TBS version 3.5.2) Convert the data item into UTF-8. (supported since TBS version 3.6.0) Deprecated. Performe the default special character conversion only if no Xml/Html entities are found inside the data item.

You can specify several values using seperator '+'. Example : htmlconv=yes+js . (dot) ifempty=val att=path If the data item is empty, then an unbreakable space is displayed. Useful for cells in tables. If the data item is empty, then it is replaced with the specified value. Move the current field into an attribute of an XML/HTML tag before it is merged. This parameter is very useful when it is too difficult for the template designer to place a TBS field into an attribute. The value path must indicate the place of the attribute relatively to the current field. If the attribute doesn't exist in the specified tag, then it is created. If the attribute already exists in the specified tag and it has already a value, then the field replaces all the current value. You can chose to place the field as an added value using parameter attadd. You can complete the attribute's value by applying a mask to it using parameter ope=msk. You can delete the attribute in case of empty value using parameter magnet=#. Syntax for value path: [+][tag1+tag2+tag3+...#]attribute By default the attribute is searched before the current field. But if '+' is the first character of the path, then it is searched after. If no tag list is specified, then the attribute is looked at in the first tag met in the search direction. If a tag list is used, tag1 is search first, then tag2, ... regardless of the direction of the search (before/after). You can put a tag name between one or several bracket levels in order to specify that the searched tag must embed the current field. Examples: [onshow.x;att=class] moves into attribute 'class' of the first tag placed before.
www.tin butstrong.com/manual.php#php_mergeblock 12/34

13/02/12

TBS Manual

[ [ [

h . ;a =di #c a ] e i a ib e 'c a ' f he fi <di > aced bef e. h . ;a =+di #c a ] e i a ib e 'c a ' f he fi <di > aced af e . h . ;a =((di ))#c a ] e i a ib e 'c a ' f he ec d e beddi g <di > aced bef e. [ h . ;a = ab e+di #c a ] e i a ib e 'c a ' f he fi <di > af e he fi < ab e> aced bef e. N e : - Me h d Me geB c () ca e a TBS fie d e a he TBS fie d aced af e i . Thi a e a TBS e cc . - Whe he a ib e ha a e bef e he fie d i ed, he TBS ch e ha i g de i i e e ega di g he a ib e (XML/HTML acce b h (") a d (')). Y ca f ce he de i i e eed i g e $TBS->A De i . Ve a add i i g: Pa a e e a i ed i ce TBS e i 3.5.0

T be ed i h a a e e a . I dica e ha he fie d i added i he a ib e' a e, i ead f bei g e aci g he a ib e' a e. P ea e e ha he added a e ' be i c ca e a ed i h e i a e ,i i be added i h a ace cha ac e e a a i de e f a addi g he ea i g f a ib e . E a e: <di c a =" e1">[ h . ;a =c a ;a add] i hi e a e, if e ha e $ = s l 2 he 't e' e b ai <di c a =" The e i a f i c ca e a e he fie d' a e i h he a e. B i ead, ca e a a e e e= i de a a a e. E a e: <di c a =" d">[ h . ;a =c a ; i hi e a e, if e ha e $ = 2 he '' Ve i i g: Pa a e e a add i be e= : e*] e b ai <di c a i =" e1 e i a e2"> a ib e' he fie d'

e2">

ed i ce TBS e

3.5.0 a a e e a ) i he ag i h ag i de (p e en ) if he en ) if he fie d' .

a a

e e= a e

T be he f ea If a fie d i If a a e E a <i Ve i

ed i h a a e e a . I dica e ha he a ib e (i dica ed i h a aged a a b a XHTML/HTML a ib e. I.e. i i ei he e e a a ib e="a ib e" i de ea TRUE, i ed i he FALSE. e i e i h a gi e a e, he he b ea a ib e i be TRUE e a hi a e, he i e i i be FALSE (omi ed). e i e ih a e, he he b ea a ib e i be TRUE (p e i e ,a di i be FALSE (omi ed) if he fie d' a e i e e : e="chec b i g: Pa a e e a ">[ e i h .acce ;a = e ec ed;a i e=1] 3.6.0

ed i ce TBS e

ag e = ag ag e =e

A ig a ag e XML/HTML e he TBS fie d. A ag e ag i e a i he he fie d ha a a e, a d i de e ed he he fie d i e i g. Pa a e e ag e he a e a a a a e e b c , i.e. ha e be a XML/HTML ag a TBS e e ded b c e e i . E a e: (<a h ef="[ h . i ; ag e =a]">c ic he e</a>) Re f $ i k ' . b . o ' (<a h ef=" ln= tscm: . b .c Re f $ i k ' : () ln=' B defa , he ag e XML/HTML e h d be de i i ed ( i e <a></a>) hich fi ag i aced bef e he TBS fie d a a e e e ( ee be ). Si ce TBS e i 3.3.0, a a e e e ha e d ( if, a a e e ag e . Re a : he a a e e if he e e a e ce ed bef e

">c ic he e</a>) b a .B i , ai f hi ca a d e i g-c i g ag be cha ged i g ) ha i e

a a e e

ag e .

e= a

T be

ed

ih

a a e e

ag e . Defi e he

ag e

e.

Va e *

Mag e beha i he fie d i e i g Tha ' he defa a e. De e e he ai f ag ha d he TBS fie d. E e hi g ha i be ee he i de e ed a . The fie d ca be i ide f he ag .

E a e: (<a h ef="[ h . i ; ag e =a]">c ic he e</a>) Re f $ i k ' . b . o ' (<a h ef=" ln= tscm: . b .c ">c ic he e</a>) Re f $ i k ' : () ln=' De e e he ai f ag ha d he TBS fie d, b ee i g e e hi g e e ha i be ee he ag . E a e: (<a h ef=" ai :[b .e ai ; ag e =a; e= + ]">[b . a e]</a>) Re f $ m i = m @ b . o ' (<a eal'etscm: h ef=" ai : e@ b .c ">M Na e</a>) Re f $ m i = ' (M Na e) eal':

www.tin butstrong.com/manual.php#php_mergeblock

13/34

13/02/12

TBS Manual

m*

Dele e he ingle ag ha i befo e he field, and e e ag and he field.

hing ha i be

een he

*m

E ample 1: <img h ef="[on ho .link;magne =img;m pe=m*]"> E ample 2: <b > ha i .add he ;magne =b e hing ha i be Dele e he ingle ag[on ho af e e field, and e ] ag and he field. E ample: [on ho .add e ;magne =b ;m pe=*m]<b > H ml ag

een he

comm

Widen he bo nd of he TBS Field p o he bo nd of he commen a o nd i , o p o ano he pecified co ple of XML/HTML ag . E ample: <!-- [m field;comm] he e ome commen o a e <di > [m field;comm=di ] he e ome commen ic l iden ical o: </di > -->

hich

[m field] Thi pa ame e i pa ic la l ef l fo he empla e de igning hen o HTML Edi o ( ch a D eam ea e o F on Page). Ve ioning: S ppo fo o he XML/HTML ag a added in TBS 3.0. noe file=filename A oid ome of he TBS E o me he me age. age . When a me

a e

ing a Vi

al

age can be cancelled, i i men ioned in

Replace he field i h he con en of he file. Filename can be a ing o an e p e ion. Yo can e he ke o d [ al] in ide he e p e ion o in e he c en da a i em. Yo can e [ a ] field in ide he e p e ion. If pa ame e c ip i ed b omi ing he filename al e (e ample: [on ho .file; c ip ; b pl]), hen he field' al e i ed fo he file name. If he file i no fo nd, hen i ill be ea ched in he folde of he la loaded empla e ( ince TBS e ion 3.2.0). E ample : [onload;file=heade .h ml] [onload;file=[ a .filename]] If filename i an emp ing, hen no e o me age i di pla ed, i i like pa ame e file i igno ed. Thi can be ed o manage condi ional in e ion. E ample: Yo [onload;file=[ a .in e ;if [ al]=1; hen 'heade .h ml';el e '']] ill fo nd mo e de ail abo hi pa ame e in he chap e S b empla e .
c ip

Se e al o: ge bod

ge bod = agli

To be ed i h pa ame e file o c ip . Indica e ha no all he file con en i onl ome XML/HTML pa of i defined i h he ag li . The ag of he li m epa a ed i h pl (+), and placed be een pa en he e if o an he ag be e ie ed i h hei con en . If he file ha e e al XML/HTML pa of a ag, all ill be a oma icall conca ena ed. If pa ame e ge bod i ed i ho al e, <bod > ag i aken b defa l . E ample: [onload;file=heade .h m;ge bod =( c ip )+( le)+bod ]

loaded b be hem el e ho e pa hen he

Ve ioning: pa ame e ge bod i ppo ed ince TBS e ion 3.0. In p e io e ion , i a a oma icall p oce ed hen ing pa ame e file. No i become e plici . The ag li i ppo ed ince TBS e ion 3.5.0. Befo e hi e ion, he al e of ge bod can be onl one ag i ho pa en he e . ename old=ne To be ed i h pa ame e file o c ip . Rename TBS block and field in he b empla e befo e i i in e ed. Yo can define e e al block o ename b epa a e hem i h coma. If a ne name i an emp ing hen he old block i dele ed b me ging i i h an emp a a . Thi pa ame e i ef l hen o an o e he ame b empla e e e al ime in he main empla e. E ample: Add e 1: [onload;file=add e Add e 2: [onload;file=add e Ve ioning: pa ame e ename i See chap e 'S b empla e ' fo mo c ip =filename .h m] .h m; ename o n1= o n2, ip1= ip2,email=] ppo ed ince TBS e ion 3.5.1. e de ail abo b empla e .

E ec e he Php c ip j befo e eplacing he TBS field. Filename can be a ing o an e p e ion. Yo can e he ke o d [ al] in ide he e p e ion o in e he c en da a i em. Yo can e [ a ] field in ide he e p e ion. If pa ame e c ip i ed b omi ing he filename al e (e ample: [on ho .file; c ip ; b pl]), hen he field' al e i ed fo he file name. If he file i no fo nd, hen i ill be ea ched in he folde of he la loaded empla e ( ince TBS e ion 3.2.0). * Take ca e ha in o c ip variables will be obsiousl local instead of global. Thi i beca e he c ip i called f om a TBS me hod. In o de o define o each global a iable in o c ip , o ha e o e he Php in c ion global o he a a $ L B L G A. * TBS gi e o o p edefined local a iable ha can be ed in o c ip :
14/34

www.tin butstrong.com/manual.php#php_mergeblock

13/02/12

TBS Manual

- $CurrVal refers to the current value of the field. It can be modified. - $CurrPrm refers to the array of field's parameters. - $this refers to the current TBS instance. (See parameter subtpl for good usage) * If the filename expression (or the value of the field) return an empty string (''), then parameter script is ignored and no error occurs. You can use this behavior in order to use a conditional insertion. See chapter 'Subtemplates' for more details about how to use this parameter in subtemplate mode. subtpl To be used with the parameter script or parameter onformat. Activate the subtemplate mode during the script or function execution. See chapter 'Subtemplates' for more details. Display the data item only if the condition is verified, otherwise display nothing unless parameter then or else are used. Supported operators are: = or == equal != not equal +greater than +=greater than or equal to -+ less than -=+ less than or equal to = match the regular expression (since TBS version 3.0) Both expr1 and expr2 must be string or numerical expressions. You can use the keyword [val] inside the expression to insert the current data item. You can use [var] fields inside the expression. The expressions may contain other TBS fields, but you have to make sure that they are merged before the containing field. Since TBS version 3.0, it is also possible to define several couples of if/then in the same field. See parameters then and else for some examples. then val1 If the parameter if is defined and its condition is verified, then the data item is replaced with val1. Since TBS version 3.0, it is also possible to define several couples of if/then in the same field. Examples: [onshow.image;if [val]='';then 'image0.gif'] [onshow.x;if [val]=1;then 'one';if [val]=2;then 'two';else 'more'] You can use the keyword [val] inside the expression to insert the current data item. You can use [var] fields inside the expression. else val2 If the parameter if is defined and its condition is not verified, then the data item is replaced with val2. Example: [onshow.error_id;if [val]=0;then 'no error';else 'error found'] You can use the keyword [val] inside the expression to insert the current data item. You can use [var] fields inside the expression. onformat=fct_name Indicates the name of a user Php function that will be executed at the time when the value is formated for the merge. This allows typically to modify the text to display. Since TBS version 3.0, it's also possible to indicate a method of a class (see OOP). The function fct_name must have the following syntax: fnto ftnm(Fedae&CrVl{$urr,&TS ){.. ucin c_ae$ilNm,$ura,&CrPm{$B . Argument Description $FieldName The name of the current field (read only). $CurrVal $CurrPrm $TBS The value of the current field. (Don' fo ge he & cha ac e in he a emen ). The function is supposed to change this value in order to format it. Optional. The PHP array containing the parameters for the current field (Don' fo ge he & cha ac e in he a emen ). Optional. Gives the current TBS instance. (Don' fo ge he & cha ac e in he a emen ). Use this argument with lot of care. It is used sometimes for the subtemplate mode.

if expr1=expr2

Example: HTML: [onshow.x;onformat=f_to_utf8] PP H: fnto ft_t8$ilNm,&CrVl { ucin _ouf(Fedae $ura) $ura=uf_noe$ura) CrVl t8ecd(CrVl; See chapter 'Subtemplates' for more details about how to use this arguments in subtemplate mode. Since TBS version 3.6.0, it's possible to limit the allowed PHP functions for parameter onformat. See create a new TBS object. protect=val Enables you to protect or unprotect the data item to be merged by replacing the characters '[' with their corresponding XML/HTML code '&#91;'. The value val can be one of the following keywords:
15/34

www.tin butstrong.com/manual.php#php_mergeblock

13/02/12

TBS Manual

e : (defa a e) da a i e i ec ed. : da a i e i ec ed. B defa , a da a e ged i h a e a e i ec ed e ce if i ' a fi e i c i . I i g ec e ded ec da a he i c e f f ee e e i e af f e a e. Ne e he e , i i ib e di ab e he ec i b defa if e e $TBS>P ec fa e. e=ac i Ma e e e e a e a i he a e be ce ed i de b e a a i g he ihc E a e: [ S h . ; e=add:-1, ed e a i a e: a : d:10] a i e .ca i h a f cha ac e . If he i g i c , he '...'. ; e= a :10] i dica e ha he a e bef e e gi g ca c i i ai e ge. Y a (,). ca defi e e e a e a i

Li i he e i g e d i e aced i h E a e: [ h - Add a a e e a H cha ac e . - Add a a e e a UTF8 cha ac e . Ve - Add a a e e a E a e: [ h A [ h he . d ig; e ic be ; he a e

f8 i dica e ha he a e bef e e gi g ca c ai i i g: a f8 i ed i ce TBS e i 3.5.2. e d cha ge he c i g b . .ca i ; e= a :10; a h ; a e d='+'] he a e d:7] e ge. E a e ge. E a he e ic . e ic . a , he i ie a e di . a ed e: e:

d: add: : di : i

e=

Add he [ h . M Di i e ie

he a e e=add:-1] e ge b e ge b he

he a e

If he a e bef e e gi g i a Ph A e a a ed i h a c a (,). E a e: [ h . a a ; e= i Add a a e e a e i de cha E a e: [ h . a a ; e= i :

] ge he i e e a a ; a e ='+']

(mean "magne ok") T be ed i h a a e e ag e . The TBS fie d i e e di a ed, b he ag e ag i e he he a e f he fie d i e a ' '. The ag e ag i de e ed i he ca e . Y ca defi e e e a a e ee he ag e ag b defi i g e e a .E a e: [ h . ; ag e =di ; e= :1, :2] ( i ed i ce TBS e i 3.5.2) (mean "magne ko") T be ed i h di a ed, b he ag e ag i de e ' '. The ag e ag i e i he ca de e e he ag e ag b defi i g e [ h . ; ag e =di ; e= :1, 3.5.2) a a e e ag e . The TBS fie d i e e ed he he a e f he fie d i e a e .Y ca defi e e e a a e e a .E a e: :2] ( i ed i ce TBS e i i h '' (e

if:

(mean "n ll if") If he a e i e a ' ' he i i e aced i g) . Thi e a i i de ig ed a e a a e e ag e a e ha ''. ( ed i ce TBS e i 3.3.0)

ih

he

(mean "magne in i ible") Re ace he a e i h '' (e i g) b a a e e ag e i c ide he d a e. Thi e a i i de ig ed a e a i i ib e a TBS fie d hich d ag e ff . ( ed i ce TBS e i 3.3.0) : (mean "ma k") A a a he a e. Cha ac e '*' i he e aced b he igi a a e. E a e: [ h .i g_id; e= ( ed i ce TBS e i 3.6.0) C C e e i he a e he a e he a e 3.8.0) e ca e. ( e ca e. ( e ca e f he fi he fi e , ed i ce TBS e ed i ce TBS e cha ac e cha ac e i i .( f each a i be :i g_*.gif]

e e

3.8.0) 3.8.0) ed i ce d. ( ed

e 1 C e TBS e e f8

C e he a e e ca e f i ce TBS e i 3.8.0) Ca be ed i h i UTF8 e c ded. 3.8.0) a , e , e 1i

e i de ed i UTF8. (

i dica e ha he a e ed i ce TBS e i

Ve i i g: - Pa a e e e i e i i ce hi e -M i e e a i f =f a

a d'

ed i ce TBS e " a d "di " a e

3.0. I

e ace

a a e e i

a 3.2.0

hich d e

'

ed i ce TBS e

S ecif a f a di a f a da a i e hich e i da e/ i e e ic. I i e a c di i a f a hich cha ge de e di g he ig f he a e. The f c ide ed a e ic e a a i c ai he cha ac e 0, he i e i i c a da e/ i e e. Da e- ime forma :

ib e a i ide ed

www.tin butstrong.com/manual.php#php_mergeblock

16/34

13/02/12

TBS Manual

It is a VisualBasic like format. The following keywords are recognized: d, dd, ddd, dddd: number of the day, number of the day in two digits, short name of the day, full name of the day. Add keyword (locale) to display locale names. xx displays st, nd, rd or th depending to the number of the day. w number of the day in the week (from 0 to 6) m, mm, mmm, mmmm: number of the month, number of the month in two digits, short name of the month, full name of the month. Add keyword (locale) to display locale names. yy, yyyy: year in two digits, full year. hh, rr, nn, ss: hour-24, hour-12, minutes, seconds forced on two digits. h, r hour-24, hour-12 ampm, AMPM : "am" or "pm" signal , "AM" or "PM" signal. (locale) Display locale day and month's names. The locale language can be set using the PHP function e l c l ( . It works only if locale parameters oae) have been set on the server. For PHP reasons, in locale mode xx does not work and d does like dd. Other characters are kept. It is possible to protect the strings inside by putting them between double quotes ("). Examples: [fld;frm=mm/dd/yyyy] will display 12/21/2002 [fld;frm='yyyy-mm-dd hh:nn:ss'] will display 2002-12-21 15:45:03 Versioning: - Keywords ampm and AMPM are supported since TBS version 3.0. - Keyword hm was supported since TBS 3.0 and is deprecated an replaced with keyword rr since TBS version 3.2.0. - Keywords rr, r, and h are supported since TBS version 3.2.0. - Keyword (locale) is supported since TBS version 3.4.0.

N me ic fo ma : To define the decimal part, use an expression like '0d0...' where 'd' is the decimal separator , and '0...' is a continuation of zeros corresponding to the number of decimals. If there is no decimal, use the format '0.' (with a dot). To define a thousand separator, use an expression like '0t000d...' where 't' is the thousand separator. If there is no decimal, use the format '0t000.' (with a dot). In order to display leading zeros, use an expression like '0000d...' where '0000' represents the number of digits you want to have. If there is no decimal, use the format '0000.' (with a dot). Versioning: This feature is supported since TBS version 3.5.2. If the format contains the character '%', then the value to display will be multiplied by 100. The character '%' is displayed too. The numerical format may contain other strings. But only the expression with one or more zeroes placed to the right will be taken as a format, other characters will be kept. Examples: Value 2456.1426 Field [fld;frm='0.000'] [fld;frm='$ 0,000.00'] [fld;frm='$ 0,000.'] [fld;frm='000000.'] [fld;frm='0.00 %'] [fld;frm='coef 0.00'] Display 2456.143 $ 2,456.14 2,456 002456 25.37% coef 0.25

0.2537

Condi ional fo ma : You have the possibility to define up to 4 conditional formats when the value is respectively positive, negative, zero or null (or empty string). Conditional formats must be separated by a ' ' character. Each conditional format is optional. Examples: Value 2456.1426 -156.333 0 null -8.75 locale Field [chp;frm='+0.00 [chp;frm='+0.00 [chp;frm='+0.00 [chp;frm='+0.00 [chp;frm='+0.00 -(0.00) * -(0.00) * -(0.00) * -(0.00) * -(0.00)'] empty'] empty'] empty'] empty'] Display +2456.14 -(156.33) * empty -(8.75)

Deprecated since TBS version 3.4.0.


17/34

www.tin butstrong.com/manual.php#php_mergeblock

13/02/12

TBS Manual

I doe plf m

he ame a

he ke

o d (locale)

ed in pa ame e f m. o can e e fo pa ame e f m. Wo k

Enable o o define fo ma in he empla e ha onl i h onload a oma ic field . E ample:

[onload; plf m ;doll=$ 0,000.00;m d = -mm-dd] [on ho .amo n ;f m=doll] ... [on ho .da e;f m=m d ] pl a Enable o ing TplVa o define a iable in he empla e ha o can e ie e in he Php p og amm p ope . Wo k onl i h onload a oma ic field .

Order of processing parameters: When o han o e e e al pa eme e in he ame TBS field, hen i can be in e ing o nde and in hich o de he a e p oce ed. Each pa ame e i changing he al e o be me ged, b he o ce f om he e he al e i i aken i no changed. O de : 1) -> Re ei ing he al e of he field o be me ged. 2) -> Changing he al e ing pa ame e : 2.1) -> onfo ma 2.2) -> ope / pl g-in OnOpe a ion 2.3) -> f m / XML/HTML o o he cha con e ion 2.4) -> if 2.5) -> file 2.6) -> c ip 2.7) -> a 2.8) -> . / ifemp / magne 3) -> In e ing he al e in he empla e.

oma ic field
A oma ic field enable o o a oma icall me ge PHP global a iable hen ome e en occ . Fo e ample [onload. ] ill be me ged i h he global a iable $ hen he LoadTempla e() me hod i called. A oma ic field can onl me ge PHP a iable when the are global. The e i no a o me ge a a iable hich i local o a f nc ion, nle o make a efe ence o i i h a global a iable, o if o me ge i ing Me geField(). A oma ic field can al o me ge TBS pecial info ma ion ( ee Special a oma ic field ), o da a of he Objec Ref p ope ( ee Obje O ien ed P og amming). The e a e h ee pe of a oma ic field : - [onload] field , hich a e a oma icall me ged hen he LoadTempla e() me hod i called. - [on ho ] field , hich a e a oma icall me ged hen he Sho () me hod i called. - [ a ] field , hich a e a oma icall me ged hen he field he a e embedded in i al o me ged i elf, b onl if he a e placed in o a pa ame e file, c ip , if, hen, el e o hen. Ve ioning: - A oma ic field [onload] and [on ho ] a e ppo ed ince TBS e ion 3.2.0. Fo compa ibili ih e o 3.2.0, emaining [ a ] field a e ill me ged a if he e e e [on ho ] field b i i ecommended o [on ho ] field in ead. - [ a ] a e p oce ed in o pa ame e hen and el e ince TBS e ion 2.02. A

o k

ion p io e eal

oma ic field ma o ma no ha e a b name, like in [onload. ], [on ho . ] o [ a . ]. An a oma ic field i ho b name ill be me ged i h an emp ing al e (''). E ample: [onload;file=heade .h ml] hi field in e a b empla e hen LoadTempla e() me hod i called. An a oma ic field ha ing a b name ill be me ged i h he co e ponding global PHP a iable. If he global a iable doe n' e i a hi momen , hen a TBS e o i di pla ed, nle o add pa ame e noe . E ample : [onload. ] hi field ill be me ged i h he global a iable $ hen LoadTempla e() i called. [on ho . ] hi field ill be me ged i h he global a iable $ hen Sho () i called. [b1.col1;if [ al]=[ a . ]; hen 'good'; el e 'bad'] : he [ a . ] field i me ged in he ame ime a [b1.col1]. Yo can al o me ge a a ' i em , objec ' p ope ie o objec ' me hod a iable a e igno ed. Fo e ample ( alid fo bo h [onload], [on ho ] and [ a ]): [on ho . bl.i em1] [on ho . bl.i em2.a.0] [on ho .obj.p op1] [on ho .obj.me hA] [on ho .obj.me hB( , )] [on ho . bl.i em3.p op2.i em4
www.tin butstrong.com/manual.php#php_mergeblock

ing a do (".") a

epa a o . Re o

ce

ill di pla ill di pla ill di pla ill di pla ill di pla ill di pla

$b[ie1] tl'tm' $b[ie2]''[] tl'tm'[a]0 $b-po1 oj>rp $b-mtA) oj>eh( $b-mtB'''' oj>eh( , ) $b[ie3]>rp[ie4] tl'tm'-po2'tm'
18/34

13/02/12

TBS Manual

Ve

ioning: calling me hod

i h a g men

f om an a

oma ic field i pe a an ime

ppo ed ince TBS e

ion 3.0.

No e: Yo

can al o fo ce he me ge of [ a ] field o o he

ing he Me geField() me hod.

Embedded a oma ic field An embedded TBS field i ne e me ged, nle : - i i me ged befo e he pa en field, - il i a [ a ] field placed in o a pa eme e file, c ip , if, hen, el e o E ample :

hen.

[onload;if [onload. ]=1; hen ' e ';el e 'no'] Thi e ample ill al a di pla 'no', beca e he embedded [onload. ] fild ill ne e be e al a ed. I i be e o e [onload;if [ a . ]=1; hen ' e ';el e 'no'] in ead, o be e : [onload. ;if [ al]=1; hen ' e ';el e 'no'] [b1.nom;block= ;heade g p=[ a . ]] In hi e ample, [ a . ] ill no be me ged e hen o call $ B - M r e l c ( b ' . . TS>egBok'1,.) The heade ill hen be defined badl . I need one of ho e: ing an onload field: [b1.name;block= ;heade g p=[onload. ]] - calling $ B - M r e i l ( v r ) a an $ B - M r e l c ( b ' . . TS>egFed'a' TS>egBok'1,.) ing a c omi ed field name: [b1.name;block= ;heade g p=[ ]] man all me ged i h $ B TS >egFed' '$) Mreil( ,x Sec i : ho o limi a he a oma ic field age in empla e ?

Yo can limi TBS objec .

oma ic field ing a

age b defining a p efi fo allo ed PHP a iable . Fo de ail , ee c ea e a ne

P e en f om p oce

oma ic field [onload] and [on ho ]

P ope ie $TBS->OnLoad and $TBS->OnSho enable o o cancel he p oce ing of [onload] and [on ho ] field . Tho e p ope ie accep onl e of fal e al e . Thi can be e ef l e peciall , b no onl , fo ome TBS pl gin . No e ha [ a ] field a e a oma icall p oce ed e en if $ B - O S o = f l e TS>nhw as. E ample: $ B - O S o = fal e; TS>nhw P ope ie OnLoad and OnSho a e ppo ed ince TBS e ion 3.6.0.

Special a

oma ic field :

A Special [ a ] field i a TBS Field hich di pla da a p o ided b he Tin B S ong em. The name of a Special [ a ] field ha o begin i h ' a ..', follo ed b a ke o d in he li belo . The pa ame e fo anda d TBS Field a e a ailable fo Special [ a ] field . E ample: Da e of he da : [on ho ..no ;f m='mm-dd( alid fo bo h onload, on ho Name on ho ..no on ho .. e ion e a ) of he e e . ']

De c ip ion Da e and ho The e

ion of Tin B

S ong. en l e ec ing.

on ho .. c ip _name

The name of he PHP file c

on ho .. empla e_name The name of he la loaded empla e file. I i he name gi en o he LoadTempla e() me hod. on ho .. empla e_da e on ho .. empla e_pa h on ho .. pl a on ho ..c .* on ho .. b _info on ho ..e o _m g .* The c ea ion da e of he la loaded empla e file.

The di ec o of he la loaded empla e file. I i he di ec o gi en o he LoadTempla e() me hod. The al e of an i em e in he TplVa p ope . ('*' m be he ke of an e i ing i em in he a a ) The al e of a PHP con an . (* m be he name of an e i ing con Info ma ion abo Di pla e o TBS and in an )

alled pl g-in . ing he ime hen p ope NoE i e o e.

ha ha e been a oid d

Ve ioning: - pecial a field "c " and " b _info" a e ppo ed ince TBS e - "e o _m g" i ppo ed ince TBS e ion 3.5.0.

ion 3.2.0.

TBS Block :
www.tin butstrong.com/manual.php#php_mergeblock 19/34

13/02/12

TBS Manual

A TBS block enables you define a zone and to display data from a record source. You can define a TBS block using one or two TBS tags (see below). Merging with data: Merging a block with data is done using the MergeBlock() method. When a TBS block is merged with data, it is repeated as many times as there are records; and the associated TBS fields are replaced by the value of the columns stored in the current record. A TBS field associated to a block is identified by its name which should be made of the name of the block followed by the name of the column to display and separated by a dot. Examples: - [Block1.ColA] This field will display the value of column ColA when block Block1 is merged. - [Blokc1.ColB;frm='dd-mm-yyyy'] Another field but with a TBS parameter. Since TBS version 3.5.0 column names with spaces are accepted. Remark: when two separated blocks have the same name, then they will be considered has two sections of the same block. All content placed between those two sections of a block will be ignored and deleted during the merging. See sections of blocks to know more about sections. Block s nta es: There are three possible syntaxes to define a TBS block: Explicit Syntax: Two TBS tags are used. One for the beginning of the block and another for the end of the block. Example: TEMPLATE...[BlockName;block=begin;params]...TEMPLATE...[BlockName;block=end]...TEMPLATE Those TBS tags for the block definition will be deleted during the merging. Relative Syntax: The block is defined by a pair of opening-closing XML/HTML tags which is given by a single TBS tag. Example: TEMPLATE...<tag_name...>...[BlockName;block=tag_name;params]...</tag_name...>...TEMPLATE This TBS tag for the block definition must be placed between the pair of XML/HTML tags. This TBS tag will be deleted during the merging. Remark: You can aslo define a block's zone by a combination of XML/HTML tags. See parameter block for more details. Simplified Syntax: An associated TBS field is used to define the block in a relative way (see the relative syntax above). Example: TEMPLATE...<tag_name...>...[BlockName.ColumnName;block=tag_name;params]... </tag_name...>...TEMPLATE The TBS tag for the block definition (i.e. the block=... parameter) must be placed between the pair of XML/HTML tags. You are nor obliged to put the parameter block on the first field, it can be any of them inside the zone defined by the block. Remarks: You should not repeat the parameter block=... on each fields of the bloc, only one is enough. If you place several of them, this will be accepted by TBS but it may bring confusions about complementary parameters for block. You can aslo define a block's zone by a combination of XML/HTML tags. See parameter block for more details. Which syntax to use? The 'absolute' syntax is rarely used with Visual Editors because TBS tags have often to be placed between two XML/HTML tags. On the other hand, it is convenient for textual editors. The 'relative' syntax enables you to indicate a block using only one TBS tag. Furthermore, there is no need to hide the TBS tag because it will be deleted during the displaying. This syntax is quite practical. The 'simplified' syntax is really simple. It enables you to define a TBS block and a TBS Field with only one TBS tag. This syntax is the most current and the most practical. Tip: You can use the 'relative' or the 'absolute' syntax with custom tags using the XML/HTML standard. Example: <custom_tag>Hello [blk1.column1;block=custom_tag], how are you?</custom_tag> Element BlockName params block=begin Description The name of the TBS block. Optional. One or several parameters from the list below. Separated with ';'. Indicates the beginning of the block.
20/34

www.tin butstrong.com/manual.php#php_mergeblock

13/02/12

TBS Manual

b c =e d b c = ag b c =e

I dica e

he e d

f he b c . ded be ee he e i g XML/HTML ag < ag...> a d he c i g XML/HTML ag d he TBS ag. The c e f i dica ed XML/HTML ag a e i eg a a f he

Defi e a b c b </ ag> hich b c. E a e:


The b c i

< ab e id=" ab1"> < >< d>[b1.fie d1;b c = ]</ d></ > </ ab e>
de fi e d b he e f a ed b i i e .

S ecia b c =_

: Defi e a b c he e i e hich h d e - i e cha . Ne i e f Wi d , Li e ef f a e a e ih e c e he TBS ag. A e a d Mac a e f e a e. i e a a e d ed. Thi fea iha e i

b c = ag/

B addi g cha ac e / a he e d f he ag' a e, TBS ' e ie e he c i g ag. The b c i be defi ed he i g e e i g XML/HTML ag hich c ai he TBS ag. Thi ca be ef i a i age f e a e.

Ve E Y N

i g:

ecia

"_" a d "/" a e he ec i i : be cce


e

ed i ce TBS 3.1.0. ' ed f e) be e d he i . e XML/HTML ag ecia

e ded b c : ca e e d he b c ' e ( a b i g he f i ge e e ha ecia a ( ee ab e


ag

e) ca

e ded b c

T e
N

e d he b c '
e: ca e cif

e e a
f diffe e

i e ag :

< ab e> < >[b1.fie d1;b c = + + ]</ >< >...</ >< >...</ > </ ab e> T e e d he b c ' e e e a cce i e ag aced bef e:

... < a >...</ a ><di >[b1.fie d1;b c = a +(di )]</di > ... O he e a e: ... < a >...</ a > <di >[b1.fie d1;b c = a +(di )+ ab e]</di > < ab e>...</ ab e> ... The ag aced be ee b ac e ea he e hich c ai he b c ' defi i i . T e e d he b c ' e a ag f he a e e b i h a highe e ca f he ag . i 3.0. Bef e. e ha , had a i e e:

<di > <di > [b1.fie d1;b c =((di ))] </di > </di > The be f b ac e ea e e ca a i e e Ve i i g : The E e ded B c fea e a a e e 'e e d' a d 'e ca ' Block' pa ame e Pa a e e da a : De c i i ha i di a ed if he e i e i hich a e

ed i ce TBS e ed a

I dica e a ec i E a e:

da a

e ge.

[b1.fie d1;b c = ] [b1;b c = ; F b ag e = ag b ag e =e e i f a i da a]The e i ab ec i

[b1.fie d2] da a. , ee he cha e 'Sec i fb c '.

I dica e a XML/HTML e hich be de e ed if he b c i e ged i h ec d (a e e ,f e a e, a PHP A a ih ie ). Pa a e e b ag e he a e a a a a e e b c , i.e. ha e be a XML/HTML ag a TBS e e ded b c e e i . E a e: [b1.fie d1;b c = ;b ag e = ab e] [b1.fie d2]
I hi e a e , he ab e i be de e e d if he e i ec d e ge .

Re a : Va e i acce ed b Me geB c () i ead f de e i g he b ag e e. If a chec e i . E a e:

e h d a a da a ce, a d i da a ce a be , he

a e a TBS e h d a e

i (snl(dt) $aa=ar (; f i_ul$aa) dt ra ) $B-Mrelc(b'$aa; TS>egBok'1,dt) Ve i i g: a a e e b ag e i ed i ce TBS e heade g =c a e I dica e a heade ec i c a e be a a id c Si ce TBS e i 3.3.0, c

3.0. a e cha ge . he
21/34

ha i di a ed each i e he a e f c c a e e ed b he da a ce. a e ca a be a i a c # $, a d i a

www.tin butstrong.com/manual.php#php_mergeblock

13/02/12

TBS Manual

subitems syntaxe of TBS fields. You can define several headergrp sections with different columns. Placement's order of headergrp sections in the block can modify the result. For more information about sections, see the chapter 'Sections of blocks'. footergrp=colname Indicates a footer section that is displayed each time the value of column colname changes. See headergrp.

splittergrp=colname Indicates a splitter section that is displayed each time the value of column colname changes. See headergrp. parentgrp=colname Indicates a parent section that is displayed each time the value of column colname changes. Unlike other sections, a parentgrp section allows normal sections inside itself. It's a way to define both a header and a footer in one section. Indicates that the block is a main block which contains serial secondary blocks. For more information, see the chapter 'serial display (in columns)'. Indicates the use of a dynamic query. All the occurrences of the string '%p1%' found in the query given to the MergeBlock() method are replaced by the value val1. For more information, see the chapter Subblocks with dynamic queries. If it used without any value, that enables you to merge several blocks of the same name. See "Merging several blocks with the same data" for more details. Define the column containing the data for an automatic subblock. For more information, see the chapter Automatic subblocks. Indicates the name of a user Php function that will be executed during the block merging. Since TBS version 3.0, it's also possible to indicate a method of a class. See OOP. The function is called each time a record is taken from the data source. You can use the arguments of such a Php function to edit records before they are merged. The function must have the following syntax: fnto ftnm(Bokae&CrRc$eNm {.. ucin c_ae$lcNm,$ure,Rcu) . Argument Description $BlockName Returns the name of the block calling the function (read only). $CurrRec Returns an associative PHP array containing the current record (read/write ; don' forge he & in he f nc ion header). If you set this variable to False, it ends the merging like it was the end of the record set. $RecNum Returns the number of the current record (read only, first record is number 1). Examples: fnto fadclm(Bokae&CrRc$eNm { ucin _d_oun$lcNm,$ure,Rcu) $ure[ln]=sre(CrRc'et]; CrRc'e' tln$ure[tx')

serial p1=val1

sub1=column1 ondata=fct_name

Since TBS version 3.6.0, it's possible to limit the allowed PHP functions for parameter ondata. See create a new TBS object. when expr1=expr2 Make the section conditional and define its condition. A conditional section is displayed only if its condition is verified. Supported operators are: = or == != ++=-+ -=+ = equal not equal greater than greater than or equal to less than less than or equal to expr1 match the regular expression expr2
(for e x pe rim e nte d use rs)

Versioning: added in TBS 3.0

Both expr1 and expr2 must be string or numerical expressions. The expressions may contain [var] fields. Example: <div>[onload;block=div;when [var.x] ='*to*'] ... </div>
The <div> block will be displaye d only if $x >0.

Note: do not confuse parameter when (which works only for TBS blocs or sections) and parameter if (which works only for TBS fields). Thus, parameter when is taken into account only if parameter block exists in the same TBS tag. See conditional blocks for more details. default several Indicates a section of block that must be displayed only if no conditional section of the same block has been displayed. Indicates that several conditional sections of the block can be displayed if several conditions are true. By default, conditional sections are exclusive.

Sections of block:
www.tin butstrong.com/manual.php#php_mergeblock 22/34

13/02/12

TBS Manual

Diffe en Sec ion - al e na - di pla - di pla

block ha ing he ame name ill be ega ded a ec ion of he ame block. can be ed o: e he di pla (no mal ec ion ), ome hing if he e i no da a (NoDa a ec ion), a heade each ime he al e of a col mn change (g o ping ec ion ).

No mal ec ion : When o define e e al no mal ec ion , he ill be ed al e na i el fo each eco d.

E ample: [b1.cap ion;block= ] [b1.cap ion;block= ]


In hi e am ple , he block nam e d 'b1' con ain back g o nd and i h a bl e back g o nd. o no m al e c ion . R e co d ill be di pla e d al e na i e l i h a g een

NoDa a ec ion: The NoDa a ec ion i a ec ion di pla ed onl if he da a o ce ha no eco d . The e can be onl one NoDa a ec ion in a block. The NoDa a ec ion i defined b adding he pa ame e noda a. E ample: [b1.cap ion;block= ] The e i no hing. [b1;block= ;noda a] G o ping ec ion : G o ping ec ion a e di pla ed e e ime a col mn' al e in he eco d- e change . Yo can define heade , foo e , pli e o pa en ec ion ing pa ame e heade g p, foo e g p, pli e g p, and pa en g p. See block' pa ame e fo mo e de ail . E ample: Yea : [b1. ea ;block= ;heade g p= ea ] [b1.cap ion;block= ] Condi ional ec ion : Condi ional ec ion a e di pla ed onl if hei condi ion i e ified. The condi ion fo di pla i defined ing pa ame e hen. A oon a a ec ion ha hi pa ame e , i become condi ional. See Condi ional di pla fo mo e de ail . E ample: [b1.name;block= ] [b1.add e ;block= ; hen [b1.add_ok]==1] [b1.amo n ]

Se ial di pla (in col mn ):


The e ial di pla enable econda block . E ample: Rec 1 Rec 5 Rec 9
In hi

o di pla

e e al eco d in ide a block. Fo

hi , o

ha e o

e a main block and

Rec 2 Rec 6 ...

Rec 3 Rec 7 ...

Rec 4 Rec 8 ...


a e he bl e line of he able , he e conda block a e he pink ce ll .

e am ple , m ain block

S n a : The main block and i econda block a e me ged ing onl one call o he Me geBock() me hod. The main block m be defined ing he pa ame e e ial. The econda block m be ne ed in o he main block. The econda block' name m be he name of he main block follo ed b "_" and a n mbe indica ing di pla o de .
www.tin butstrong.com/manual.php#php_mergeblock 23/34

13/02/12

TBS Manual

E [ [
T

: ; _1. = ; ; ] [ ]
:

_2.

] [

_3.

] [

_4.

PHP

$B-Mrelc(b'$n_d'EETttFO tif ODRB tt) TS>egBok' ,c i,SLC RM _no RE Y ' E Y T : "E " , 0. I .T " " . ( ).

E [ [ [ ; _1.

: = ; ; ] [ ]

_2.

] [

_3.

] [

_4.

; = ; ] [ _0; = ] No records fo nd. :

R T

S
A E P

:
TBS : #1 S S P S S S P S T -A S -S . A : .S .P :( TBS 3.5.0) .A . #1.1 #1.2 #2 #2.1 #2.2 #2.3 #3 #3.1 TBS: 1 () , . TBS

.N

1 .

()

A
A Y 2, 3, ... T 2, _ 3, ...) :

:
TBS .S 3.5.0. 1= _ .S
24/34

1, (

.I

_ T

www.tin butstrong.com/manual.php#php_mergeblock

13/02/12

TBS Manual

PHP

TBS (

(,).

- )

E N [
C

: :[ _ . 1. ; ; = ; = ]
:

1=

PHP

$B-Mrelc(bd'$n_d'EETnm,pkngFO tbd) TS>egBok'o ,c i,SLC aesoel RM _o


R :

N US FR N US N FR ES IT H

:P

:P :J

:I TBS E N [ : :[ _ . 1. ; ; = ; = ] 3.6.0.

.T

PHP

.O

1=(

)]

TBS

( .D

): I TBS 3.6.1.

E : $aa=ar (; dt ra ) $aa'ru1]=ar (; dt[gop' ra ) $aa'ru1]]=ar (i'>,'ae='ee'; dt[gop'[ ra 'd=1 nm'>ptr) $aa'ru1]]=ar (i'>,'ae='al) dt[gop'[ ra 'd=2 nm'>pu'; $aa'ru2]=ar (; dt[gop' ra ) $aa'ru2]]=ar (i'>,'ae='ue'; dt[gop'[ ra 'd=3 nm'>jls) $aa'ru2]]=ar (i'>,'ae='i'; dt[gop'[ ra 'd=4 nm'>jm) E G [ : :[ _ .$; 1. ; = ; 1] = ]

S
P I I T E , M M B B :

() () 1, 2, 3,...

1, 2, 3,... . % 1%, % 2%, % 3%, ...

.T

1 1.

E C [

: :F ;

= ; 1='

'] [

]
25/34

www.tin butstrong.com/manual.php#php_mergeblock

13/02/12

TBS Manual

C [b .
C e

: USA ;b c = ; 1='
di g PHP c de :

']

[b .c

$B-Mrelc(bk,c _d"EETt ncut FO tgoWEE(onr=%1'" TS>egBok'l'$n i,SLC o ,onr RM _e HR cut 'p%))


Re f he e ge :

C Pa i T C B U e ih

: F a ce f a ce e : USA f a ce

Wa hi g

bb c

: a ai -b c ih bb c . He e i h ai b c . h e a e i a fie d f he ai b c . he bb c . ca d i:

D a ic e ie e ab e ea i b i d a e f - C ea e a ai b c , a d he a bb c i ide he - Li he b addi g he bb c a a a e e 1 - A he PHP ide, e ge he ai b c fi , a d he E a e:

C : [ ai .c ;b c = ] [ b. ;b c = ; 1= [ ai .c _id]]
C e di g PHP c de :

$B-Mrelc(mi'$n_d'EETcut ,nri FO tcut ' TS>egBok'an,c i,SLC onr ct_d RM _onr ) $B-Mrelc(sb,c _d'EETt nFO tt nWEE(nri=p%' TS>egBok'u'$n i,SLC o RM _o HR ct_d%1))
Re f he e ge :

C Pa i T C Be i M ich

: F a ce e : Ge a

C : S ai Mad id Ba ce a Re a : - The a a e e h c - The d a ic e ie a

=e c e ab e i h ec i

a ec ed i g a e f b c a d e ia di a .

he

A
A

a ic b c
a ic b c

:
e ab e a a ica : e ge c di i a b c he e e e cc .

The e a e -[ ad] b c -[ h ]b c

e fa a ic b c hich a e e ged a hich a e e ged a

a ica a ica

he he L adTe he he Sh () h he ca di i a ec i

a e() e h d i ca ed. e h d i ca ed. ha e . C di i a ec i ( c a e e a a ed di i a ec i ) ce, a d he

A a ic b c a e e ged i h da a ; ha ' a d i ed fie d . A a ic b c ca ha e c be e e i c ai i g [ a ] fie d . E a [ [ If e: ad;b c = ; he h eed ;b c = ; he ha e a g [ a . igh ]=1]Ligh i ON. [ a . fe c e ]=1] U e : [ i e ec i ,

h ih

e ih

a e] a defa ec i , ca ffi he [ ad] a d


26/34

www.tin butstrong.com/manual.php#php_mergeblock

13/02/12

TBS Manual

] b c'

a e

i h "_" f

ed b a

a e.

E a [ [ [ See C

e: ad_ ig h;b c = ; he ad_ ig h;b c = ; he ad_ ig h;b c = ;defa di i a ec i f [ a . igh ]=1] Ligh i ON. [ a . igh ]=0] Ligh i OFF. ] Ligh i ? e de ai .

S b e

a e :
a i e b e a e i ai e a e.

The e a e Primar Thi i

insertion using parameter file: he be a i i e a a c ai ed i a he fi e, i e a d e f heade e a di i a df e . ih .

The a e gi e a a e e fi e be he a e f a fi e e i i g he e e . Y ca [ a ] Fie d a d he [ a ] e d hich e e e he a e f he fie d. If he a e i a e e e age i di a ed, i i i e a a e e fi e i ig ed. Thi ca be ed a age c E a [ [ [ [ C [ e : ad;fi e=heade .h ] ad;fi e=[ a .fi e_heade ]] ad. b1;fi e=[ a ]] ad;fi e=[ a .i e ;if [ a ]=1; he

e e i i g, he a i e i

'heade .h

';e e '']] cha c .[ h e i ] ag a d i be TBS e ged i ec i . he Sh ()

e f he fi e i i e ed a he ace f he fie d, i h ad] ag c ai ed i he fi e a e ce ed a he i e i e h d beca e he beca e a f he ai e a e.

The da a e Y

b e a e ca c ai a TBS fie d , i c di g [ a ] fie d a d b c be e ged. If i h a b c defi ed i a b e a e, he i ' gge ed e a a e e fi e i a [ e ha he b e a e i i e ed bef e ca Me geB c ().

e d e ge ad] fie d i de a e he TBS

ca c ea e a b e a e i a i de e de XML/HTML/Te fi e, a d a TBS i c de i he ai e he <b d > a ( a he a ). Thi ca be d e b addi g a a e e ge b d a a e e fi e i fie d f he ai e a e. Thi ech i e e ab e WYSIWYG i h b e a e . Insertion driven with Php code using parameter subtpl: Pa a e e b i ef a age b e ed i h a a a e e c i f a .I f ci e ec i a d ca ac a e e The S b e a e de e e he f a e i e i i h Ph c de. Pa a e e b he c e TBS i a ce i S b e a e a e ih de e i a i g he ai e a e.

i ac i e he de d i g he c i

i g cha ac e i ic : ace i ead f bei g i i he ai e a e i b- e ge i he ai edia e e he c ie ead f be di ec e a e. .F e a e, i g i . U i g he Sh ()

* Ph a e di a ed a he fie d' he Ph c a d ech () i i e a e e h d i a i e he e f he * A efe e ce f a . Thi ' a Whe E a he c i he TBS i a ce i a iab e be ed f c i e ec i d he f


ci

ided b ca a iab e $ hi $TBS, he he e b e ge ih de e i a i g he ai i g he S b e a e de i e i d e b defa a ce e i a de

e i

e a a e e ci a e. The Sh () e h d a de. ai TBS e a e.

ci
:

e d , he TBS i

i h he

e ih a a e e HTML: PHP c i :

ad.fi e; c i

ecia b

. h ;

<pp ?h eh(*Hr icueasbepae*) co' ee nld utmlt '; $hs>odepae$ura) ti-LaTmlt(CrVl; $hs>egBok'l1,GOAS'oni',SLC *FO tbe'; ti-Mrelc(bk'$LBL[cn_d]'EET RM al1) $hs>h (; ti-So ) ? >
$C Va i a ca a iab e ide d b TBS he i g a a e e ci ; hi a iab e i a e fe e ce he a e f he fie d c e e ge d. I he e a e ab e , $C Va ha he a e f he g ba a iab e $fi e . Y ca e ace i , f e a e , b he a e f he b e a e ad (f e a e: ' b .h '). Se e a a e e ci f e i f a i .

Re a

www.tin butstrong.com/manual.php#php_mergeblock

27/34

13/02/12

TBS Manual

Example with param e te r onform at: HTML: [onload.user_mode;onformat=f_user_info;subtpl]

PHP user function: f n t o f u e _ n o $ i l N m , $ u r a , $ u r r , $ B ) { ucin _srif(Fedae&CrVl&CrPm&TS i (CrVl=){/ Ue i lge i f $ura=1 / sr s ogd n $B-LaTmlt(ue_nohm) TS>odepae'srif.t'; $B-Mrelc(bk'$LBL[cn_d]'EET*FO tbe'; TS>egBok'l1,GOAS'oni',SLC RM al1) $B-So(; TS>hw) es {/ Ue ntlge i le / sr o ogd n eh(Yuaentlge i.) co'o r o ogd n';

Remarks:

$C urrVal is a variable de clare d as an argum e nt of the function. It's TBS that is in charge to call this function m ak ing $C urrVal re fe rring to the value of the fie lds curre ntly m e rge d. In this e x am ple above , $C urrVal is e qual to the global variable $use r_m ode . In the sam e way, variable $C urrPrm is a re fe re nce to the array of param e te rs of the fie ld curre ntly m e rge d, and $TBS is a re fe re nce to the TinyButStrong instance curre ntly use d. Se e param e te r onform at for m ore inform ation.

Conditional display overview:


TinyButStrong offers several tools for conditional display for both fields and blocks. Condi ional field For any TBS fields you can use parameters for conditional display, recalled below. Parameter . (dot) ifempty=value2 magnet=tag if condition then value1 else value2 frm=format1 format2 format3 format4 Description Display an Html unbreakable space if the field value is empty. Display value2 if the field value is empty. Delete a tag or a pair of tags if the field value is empty. Display value1 or value2 depending on whether the condition is verified or not. Changes the numeric format or date/time format depending on whether the value is positive, negative, zero or empty.

Example: [onshow.error_id;if [val]=0;then 'no error';else 'error found'] Condi ional ec ion You can use conditional sections any TBS block (data block or automatic block). A conditional section is a section which has a parameter when defining a condition, or parameter default. At the block's merging, each when condition of conditional sections is evaluated until one is verified. As soon as one when condition is verified, its conditional section is kept and other conditional sections are deleted. If no when condition is verified, then the default section is displayed if it exists. The case of data blocks: If it is a data block, it means a block merged with MergeBlock(), then the conditional sections are reassessed for each record. It is even possible to define a data block with only conditional sections, with no standard section. Defining the conditions: The conditions defined into parameters when can be expressions that contain [var] fields et and linked fields (if it is a data block). See parameter when for more details about operators supported by TBS. Section exclusivity: By default conditional sections are exclusive inside a block. It means only one conditional section of a block can be displayed. But if you want a block to have non-exclusive conditional sections, you can use parameter several on the first conditional section. With this parameter, all conditions are evaluated and each true condition makes its section to be displayed. Example with a data block: Name: [b1.Name;block=tr] Address: [b1.add_line1;block=tr;when [b1.address]=1] [b1.add_line2] [b1.add_zip] - [b1.add_town] No address.[b1;block=tr;default] Example with an automatic block:
www.tin butstrong.com/manual.php#php_mergeblock 28/34

standard section conditional section

default conditional section (optional)

13/02/12

TBS Manual

[onload_err;block=tr;when [var.email]='';several] Your email is empt . [onload_err;block=tr;when [var.name]=0] Your name is empt . [onload_err;block=tr;default] All is ok.

www.tin butstrong.com/manual.php#php_mergeblock

29/34

13/02/12

TBS Manual

Coding plug-ins:
You can add features to TinyButStrong using plug-ins. The da aba e pl g-in simply enable the method MergeBlock() to recognize new types of database. The o he pl g-in enable you to add features to TBS or to modify its main methods in order to make it more specialized. In both cases, a plug-in is made of a set of PHP functions or one PHP class which have to fit with a special syntax expected by TBS. Some plug-ins are proposed for download at the TinyButStrong web site.

Database plug-ins:
Versioning: database plug-ins are supported since TBS version 1.8. A database plug-in enables the method MergeBlock() to recognize a new type of database. When you have a call such as $TBS->MergeBlock($BlockName, $Source, $Query), the MergeBlock process is first examining $Source to see if its type is supported. If $Source is a type of resource known in native by TBS, then the MergeBlock process doesn't need any plug-in help, it will retrieve the data by its own. If $Source is an object having a method named tbsdb_open() then the MergeBlock process assumes that the object is a database plug-in and use it to retrieve the data. (See more details below) If $Source is a string beginning with '~' then the MergeBlock process assumes that property $TBS->ObjectRef is a database plug-in and use it to retrieve the data. (See more details below) If $Source is something else then the MergeBlock process is trying to found the plug-in made by user functions that correspond to the type of $Source. (See more details below) Da aba e pl g-in ba ed n e f nc ion :

When the MergeBlock process meet a type of value for $Source which is not supported in native, it determines the TBS Id corresponding to that type. Then it looks for the user functions corresponding to that TBS Id. How to determine the TBS Id: The TBS Id is a string identifier determined by the argument $Source. If $Source is a string => the TBS Id is that string. If $Source is a PHP resource => the TBS Id is the name of the resource's type. If $Source is an object => the TBS Id is the name of the class. For some convenience, if the TBS Id contains spaces (' '), it is cut. If the TBS Id contains '-', they are replaced with '_'. For example, a PHP variable for a Sybase connection is typed as Resource and its resource name is 'sybase-db link'. The corresponding TBS Id is 'sybase_db'. How to build the plug-in for a TBS Id: The plug-in is made of 3 user functions which must have specific names. The following function names are made for a TBS Id which is 'tbsid'. For another TBS Id, you just have to rename the functions. You can found several examples of database plug-in at the TinyButStrong web site. Synopsis: function b db_ b id_open(&$Source, &$Query) This function is called one time by the MergeBlock process, before the other user functions. It is supposed to use $Source and $Query to open a recordset, and return a reference of that recordset. function b db_ b id_fe ch(&$Rs [,$RecNum]) This function is called several times by the MergeBlock process, as many times as there are data to fetch from the query. This function should return the next record as an associative array (column name=> value), or return false if there is no record left. $Rs is the value provided by b db_ b id_open(). It is commonly a recordset's reference. $RecNum can be useful for some database type such as Oracle, for which the number of the record is needed to retrieve it. function b db_ b id_clo e(&$Rs) This function is called on time by the MergeBlock process, after the other user functions. This function should close the recordset properly. $Rs is the value provided by b db_ b id_open(). It is commonly a recordset's reference. Da aba e pl g-in ba ed on objec : When the MergeBlock process meet of value for $Source which is an object, and if that object has a method named b db_open(), then it assumes that the object is a database plug-in. The object must have at least the 3 methods b db_open(), b db_fe ch() and b db_clo e(). There can be other methods and properties, but those 3 methods must have the same syntax and the same feature as the user functions described above. Synopsis: class clsTbsPlugin {
www.tin butstrong.com/manual.php#php_mergeblock 30/34

13/02/12

TBS Manual

function tbsdb_open(&$Source, &$Query) function tbsdb_fetch(&$Rs [,$RecNum]) function tbsdb_close(&$Rs)

Database plug-in based on propert ObjectRef: When the MergeBlock process meet a value for $Source which is a string beginning with '~' then it assumes that property $TBS->ObjectRef is a database plug-in based on object (see OOP). The object must have the same requirements as a database plug-in based on objet described above, but the names of the methods can be different. Example: $TBS->MergeBlock($BlockName,'~dbkey',$Query); class clsTbsPlugin { function dbkey_open(&$Source, &$Query) function dbkey_fetch(&$Rs [,$RecNum]) function dbkey_close(&$Rs) }

Other plug-ins:
Versioning: plug-ins are supported since TBS version 3.0. Coding a plug-in using a PHP class: Plug-in's key: Each plug-in has a plug-in key which is the name of its Php class. This key must be given to the method PlugIn() when you use it. Thus, it is recommended to define a PHP constant for the plug-in's key (see example below). Plug-in events: A TBS plug-in must be a PHP class which contains one or several specific methods that will be recognized and plugged by TBS. Those specific methods are called plug-in events because they are executed automatically by TBS when the corresponding event occurs. A TBS plug-in can also have other methods and properties for internal purpose. A TBS plug-in must have at least the OnInstall event. For example: / TSpu-nXX / B lgi X dfn(TSXX,csbPuIgXX) / Ta i tepu-nsky eie'B_X''lTslgn_X'; / ht s h lgi' e cascsbPuIgXX){ ls lTslgn_X( fnto OIsal.. {. / Ta i teOIsaleet ucin nntl(.) .. / ht s h nntl vn .. .

See the PHP file "tbs_plugin_syntaxes" to have all plug-in events, their usage and expected arguments. There is also a list of supported events at the bottom of this section. The OnInstall event is special. It has to return an array with all activated events for the current plug-in (see the PHP file "tbs_plugin_syntaxes"). The OnInstall event is called when the plug-in is installed at the TBS instance. This event can be called in three situations: - When using method PlugIn() with the plug-in's key for the first time. - When using method PlugIn() with the plug-in's key and the argument TBS_INSTALL. - When a new TBS instance is created, if the plug-in's key has be added to the global array $_TBS_AutoInstallPlugIns[] (see file "tbs_plugin_syntaxes.php" for more details). Property ->TBS: As soon as the plug-in is installed on the TBS instance, a property - T Sis automatically added to the plug-in, its >B value is a reference to the parent TBS instance. Remember this because this property can be very useful inside the plug-in's code. Coding a plug-in using PHP functions: The plug-ins' key is a string that you choose and which will be used for naming the function. It is recommended to define a PHP constant for the plug-in's key (see example below). The plug-in events are coded using functions, and they names must be the string 'tbspi_', followed by the plug-in's key, followed by '_' and the event's name. Example: dfn(TSXX,xx) eie'B_X''x'; fnto tsixxOIsal.. {. ucin bp_x_nntl(.) ..
www.tin butstrong.com/manual.php#php_mergeblock 31/34

13/02/12

TBS Manual

All the rest works like for plug-in coded with a class. You must have at least the event OnInstall created, and it works the same way. Remark: PHP functions are often faster than methods, but they don't let you having a ->TBS property to reach the parent TBS instance. Li of pl g-in e en : Plug-in Events OnInstall OnCommand Description Executed automatically when the plug-in is called for the first time, or when PlugIn() method is called with the specific argument for installing. Executed when PlugIn() method is called. This is a way to execute any user command specific to the plug-in. Executed at the end of LoadTemplate(). Executed when Show() method is called. Can cancel TBS basic process. Executed at the end of Show(). Executed each time a record of data is retrieved for a MergeBlock() process. (similar to parameter 'ondata' but for every block) Executed each time a fields is being merged. (similar to parameter 'onformat' but for every fields) Executed each time parameter 'ope' is defined with an unsupported keyword. Executed each time a field is put in the cache of a Block definition. (supported since TBS 3.6.0) Executed when bounds of a block are founded. Can cancel TBS basic process. Executed when a section is merged, and before it is added to other sections. Executed before a header, a footer or a splitter section is merged. (supported since TBS 3.3.0) Executed just before a merged block is inserted into the template. Executed when a non native Special Var Field (like [onshow..now]) is met. Executed on each field met when using the MergeField() method.

BeforeLoadTemplate Executed when LoadTemplate() method is called. Can cancel TBS basic process. AfterLoadTemplate BeforeShow AfterShow OnData OnFormat OnOperation OnCacheField BeforeMergeBlock OnMergeSection OnMergeGroup AfterMergeBlock OnSpecialVar OnMergeField

www.tin butstrong.com/manual.php#php_mergeblock

32/34

13/02/12

TBS Manual

S TBS F
P

: '
S C .( ) I I M U U I U I U U E A U U P E A I E U U U P .I .R .T TBS TBS . . . . TBS ' . . . . P .D .D '['. C . . . . . . , . . .I .I , . . M , , XML/HTML . . ' ' . .

TBS B
P

'
S D I I I I I I 1 1 S D E U U U

'

. . . . . . . . .

P .D .D .I . . .

:
33/34

www.tin butstrong.com/manual.php#php_mergeblock

13/02/12

TBS Manual

Name val # $ onload onshow var

Summar The ke word [val] can be used in field's parameters to represent the field's value. Virtual column name for a block. It displa s the record's number. Virtual column name for a block. It displa s the record's ke if the data source is a Php Arra . Automatic field or block, merged when the template is loaded. Automatic field or block, merged when the template is shown. Embedded automatic field.
.**..**..**..**..**..**..**..**.. : :_: :_: :_: :_: :_: :_: :_: :_:

www.tin butstrong.com/manual.php#php_mergeblock

34/34

Potrebbero piacerti anche