-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathtbs_us_manual.htm
7764 lines (7046 loc) · 414 KB
/
tbs_us_manual.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>TBS Manual</title>
<style type="text/css">
<!--
.pagebreak {
page-break-before:always;
}
.tbsname {
font-size: 12px;
font-weight: bolder;
color: #4D3A81;
}
.norm {
margin-left: 30px;
padding: 5px;
border: 1px solid #999999;
margin-top: 12px;
margin-bottom: 12px;
}
.decal {
margin-left: 20px;
padding: 2px;
margin-top: 3px;
}
h1 {
margin-top: 8px;
margin-bottom: 8px;
font-size: 16px;
}
h2 {
font-weight:normal;
font-size: 16px;
text-decoration: underline;
background-color: #6699CC;
margin-top: 20px;
margin-bottom: 20px;
}
h3 {
margin-top: 20px;
margin-bottom: 20px;
font-weight:normal;
font-size: 16px;
text-decoration: underline;
}
h4 {
text-decoration: underline;
font-weight:normal;
font-size: 12px;
margin-top: 8px;
margin-bottom: 6px;
}
h5 {
font-weight: bold;
font-size: 12px;
margin-top: 3px;
margin-bottom: 3px;
}
h6 {
text-decoration: underline;
font-weight:normal;
font-size: 12px;
margin-top: 8px;
margin-bottom: 6px;
}
th {
text-decoration: underline;
text-align:left;
vertical-align:top;
font-weight:normal;
}
pre {
font-size:12px;
}
.title-1c {
font-weight: bold;
}
.txt-small {
font-size: 10px;
}
.txt-code {
font-family: "Courier New", Courier, mono;
font-size: 12px;
}
.txt-tiny {
font-size: 9px;
margin-top:0;
margin-bottom:0;
}
table {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
td {
margin-top:0;
}
p {
margin-top:4px;
}
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
.opt-name {
color: #990000;
}
a.opt-name {
color: #990000;
text-decoration:none;
}
a.opt-name:hover {
color: #990000;
text-decoration:underline;
}
.opt-value {
color: #000099;
}
.opt-html {
color: #006600;
}
.opt-type {
font-style: italic;
color: #0033CC;
}
.border-0 {
border: 1px solid #999999;
}
.border-1 {
border: 1px solid #FF3399;
}
.border-2 {
border: 1px solid #336699;
}
.border-3 {
border: 1.5px solid #CC6600;
}
.border-sep {
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #999999;
}
.versioning {
background-color: #EAEAEA;
margin: 12px 0 12px 0;
padding: 0 0 2px 0;
}
.versioning > p {
/* <p> inside a class "versioning" */
margin: 0;
}
.list-mini {
margin: 0;
padding-left: 20px;
}
.blockzone {
border: 1px dotted #666666;
padding: 2px;
margin: 2px;
}
.blocksep {
border-left-width: 1px;
border-left-style: dotted;
border-left-color: #666666;
}
.contextual {
padding: 1px;
border: 1px dotted #6699CC;
}
.note {
background-color: #D9FFD9; /* green */
border: thin solid #00EC9F;
padding: 2px;
margin-top: 3px;
margin-left: 20px;
}
.warning {
background-color: #f4dfdf; /* light red */
}
-->
</style> </head>
<body style=" background-color: white;">
<div id="main-body">
<div class="txt-tiny" style="display:inline-block; float:left;">
<table class="txt-tiny" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td width="50">Site:</td>
<td><a href="http://www.tinybutstrong.com" target="_top">www.tinybutstrong.com</a></td>
</tr>
<tr>
<td>Date:</td>
<td>2024-05-08</td>
</tr>
</tbody>
</table>
</div>
<div style="margin:auto; width:500px; text-align:center;">
<h1>TinyButStrong Documentation</h1>
<div class="txt-tiny">version 3.15</div>
<div style="margin-top:10px;">Template Engine for Pro and Beginners<br>
PHP 8<br>
PHP 7<br>
PHP 5 </div>
</div>
<h2>Table of Contents:</h2>
<div class="norm">
<table cellspacing="0" border="0">
<tbody>
<tr class="title-1c">
<td width="300"> Subject</td>
<td>Description</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><a href="#introduction" class="title-1c">• Introduction</a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#principles">Basic principles</a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#installation">Installation</a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#examples">Mini examples</a></td>
<td> </td>
</tr>
<tr>
<td><a href="#php_side" class="title-1c">• PHP side</a></td>
<td> </td>
</tr>
<tr>
<td> • To begin</td>
<td> </td>
</tr>
<tr>
<td> <a href="#php_instanciate">create
a new TBS object</a></td>
<td> for working with templates</td>
</tr>
<tr>
<td> <a href="#php_loadtemplate"><span
class="txt-small">method</span> LoadTemplate()</a></td>
<td>load the contents of a template from a file</td>
</tr>
<tr>
<td> <a href="#php_mergeblock"><span
class="txt-small">method</span> MergeBlock()</a></td>
<td>merge a part of the template with a data source</td>
</tr>
<tr>
<td> <a href="#php_show"><span
class="txt-small">method</span> Show()</a></td>
<td>automatic processing and display of the result</td>
</tr>
<tr>
<td> • Advanced</td>
<td> </td>
</tr>
<tr>
<td> <a href="#php_getblocksource"><span
class="txt-small">method</span> GetBlockSource()</a></td>
<td>returns the source of the definition of a block</td>
</tr>
<tr>
<td> <a href="#php_mergefield"><span
class="txt-small">method</span> MergeField()</a></td>
<td>merge a specific field with a value</td>
</tr>
<tr>
<td> <a href="#php_setoption"><span
class="txt-small">method</span> SetOption()</a></td>
<td>set TBS options</td>
</tr>
<tr>
<td> <a href="#php_getoption"><span
class="txt-small">method</span> GetOption()</a></td>
<td>get TBS options</td>
</tr>
<tr>
<td> <a href="#php_resetvarref"><span
class="txt-small">method</span> ResetVarRef()</a></td>
<td>reset the VarRef property</td>
</tr>
<tr>
<td> <a href="#php_getvarrefitem"><span
class="txt-small">method</span> GetVarRefItem()</a></td>
<td>get an item in the VarRef property</td>
</tr>
<tr>
<td> <a href="#php_setvarrefitem"><span
class="txt-small">method</span> SetVarRefItem()</a></td>
<td>set an item in the VarRef property</td>
</tr>
<tr>
<td> <a href="#php_replacefields"><span
class="txt-small">method</span> ReplaceFields()</a></td>
<td>replace simple fields with long fields</td>
</tr>
<tr>
<td> <a href="#php_getattvalue"><span
class="txt-small">method</span> GetAttValue()</a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#php_plugin"><span
class="txt-small">method</span> PlugIn()</a></td>
<td>execute a plug-in's action </td>
</tr>
<tr>
<td> <a href="#php_varref"><span
class="txt-small">property</span> VarRef</a></td>
<td>set variables to be merged with automatic fields</td>
</tr>
<tr>
<td> <a href="#php_assigned"><span
class="txt-small">property</span> Assigned</a></td>
<td>prepares information for a subsequent merging</td>
</tr>
<tr>
<td> <a href="#php_source"><span
class="txt-small">property</span> Source</a></td>
<td>returns the current contents of the result</td>
</tr>
<tr>
<td> <a href="#php_tplvars"><span
class="txt-small">property</span> TplVars </a></td>
<td>returns template variables </td>
</tr>
<tr id="v202_oop_plan">
<td> <a href="#php_oop">Object
Oriented Programming (OOP) </a></td>
<td>to make TBS OOP friendly </td>
</tr>
<tr>
<td><a href="#html_side" class="title-1c">• Template side</a></td>
<td> </td>
</tr>
<tr>
<td> • TBS fields</td>
<td> </td>
</tr>
<tr>
<td> <a href="#html_field">Definition
and syntax</a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#html_field_prm">Parameters</a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#html_field_prm_order">Order
of processing parameters</a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#html_field_auto">Automatic
fields</a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#html_field_special">Special
automatic fields</a></td>
<td> </td>
</tr>
<tr>
<td> • TBS blocks</td>
<td> </td>
</tr>
<tr>
<td> <a href="#html_block">Definition
and syntaxes </a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#html_block_prm">Parameters</a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#html_block_section">Sections
of block</a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#html_block_auto">Automatic
blocks </a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#html_block_parallel">Parallel
merge (dynamic columns) </a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#html_block_serial">Serial
display (in columns) </a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#html_block_subblock">Subblocks</a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#html_block_subauto">Automatic
subblocks</a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#html_block_dynsb">Subblocks
with dynamic queries</a></td>
<td> </td>
</tr>
<tr>
<td> • Miscellaneous</td>
<td> </td>
</tr>
<tr>
<td> <a href="#html_subtemplate">Subtemplates</a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#html_conditional">
Conditional display overview</a></td>
<td> </td>
</tr>
<tr>
<td><a href="#coding" class="title-1c">• Improve TBS by coding</a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#coding_extended_methods">Extended
methods</a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#coding_block_alias">Block
alias</a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#plugins_db">Data Reader
Plug-ins</a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#plugins_tbs">Other plug-ins</a></td>
<td> </td>
</tr>
<tr>
<td><a href="#summaries" class="title-1c">• Summary</a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#appendix_field">TBS Field's
parameters</a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#appendix_block">TBS Block's
parameters</a></td>
<td> </td>
</tr>
<tr>
<td> <a href="#appendix_specialname">Names
of Special Fields and Blocks</a></td>
<td> </td>
</tr>
</tbody>
</table>
</div>
<h2 id="introduction" class="pagebreak">Introduction:</h2>
<p><strong>TinyButStrong</strong> (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. </p>
<p> 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.</p>
<p> 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.</p>
<p> As the name of it tells, TBS is easy to use, strong and fast. It is
completely <span style="color:#009900">°~° freeware °~°</span>. </p>
<h3><a id="principles"></a>Basic principles:</h3>
<p>On the HTML side (or other file type):</p>
<p class="decal"> 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'.</p>
<p class="decal"> There are two types of tags: the <a href="#html_field">'fields'</a>
which are used to display dynamic data items, and the <a href="#html_block">'blocks'</a>
which are used to define an area, mostly in order to display records
from a data source.</p>
<p> On the PHP side:</p>
<p class="decal"> 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. </p>
<h3><a id="installation"></a>Installation:</h3>
<ol>
<li>Copy the file <span class="opt-html">tbs_class.php</span> in a
directory of your Web site.</li>
<li>At the beginning of your PHP program, add the lines:
<pre class="decal txt-code">include_once(<span class="opt-value">'tbs_class.php'</span>);
<span class="opt-name">$TBS</span> = new clsTinyButStrong; </pre>
<p><span class="txt-small">Remark: if the TBS file tbs_class.php is in
a different directory than your application, then you have to
precise the directory in front of the TBS file name.</span></p>
</li>
</ol>
<h4>Explanations and technical details:</h4>
<p>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.</p>
<p> 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. </p>
<h3><a id="examples"></a>Mini examples:</h3>
<p>Example 1: </p>
<table cellspacing="4" cellpadding="2" border="0">
<tbody>
<tr>
<th width="320">Html Template</th>
<th width="320">Php Program</th>
<th>Result</th>
</tr>
<tr>
<td valign="top">
<pre class="opt-html"><html>
<body>
[onshow.message]
</body>
</html>
</pre></td>
<td valign="top">
<pre class="txt-code"><?php
include_once(<span class="opt-value">'tbs_class.php'</span>);
<span class="opt-name">$TBS</span> = new clsTinyButStrong;
<span class="opt-name">$TBS</span>->LoadTemplate(<span class="opt-value">'template.htm'</span>);
$message = <span class="opt-value">'Hello'</span>;
<span class="opt-name">$TBS</span>->Show();
</pre></td>
<td valign="top">
<pre class="opt-html"><html>
<body>
Hello
</body>
</html></pre>
</td>
</tr>
</tbody>
</table>
<p>Example 2: </p>
<table cellspacing="4" cellpadding="2" border="0">
<tbody>
<tr>
<th width="320">Html Template</th>
<th width="320">Php Program</th>
<th>Result</th>
</tr>
<tr>
<td valign="top">
<pre class="opt-html"><table>
<tr><td>[blk.val;block=tr]</td></tr>
</table></pre>
</td>
<td valign="top">
<pre class="txt-code"><?
include_once(<span class="opt-value">'tbs_class.php'</span>);
<span class="opt-name">$TBS</span> = new clsTinyButStrong;
<span class="opt-name">$TBS</span>->LoadTemplate(<span class="opt-value">'template.htm'</span>);
$list = array(<span class="opt-value">'X'</span>,<span class="opt-value">'Y'</span>,<span
class="opt-value">'Z'</span>);
<span class="opt-name">$TBS</span>->MergeBlock(<span class="opt-value">'blk'</span>, $list);
<span class="opt-name">$TBS</span>->Show();
</pre></td>
<td valign="top">
<pre class="opt-html"><table>
<tr><td>X</td></tr>
<tr><td>Y</td></tr>
<tr><td>Z</td></tr>
</table></pre>
</td>
</tr>
</tbody>
</table>
<a id="php_side"></a>
<h2>PHP side:</h2>
<p>The merging of a template is done in a PHP program using an object
variable declared as a <span class="opt-html">clsTinyButStrong</span>
class.</p>
<p> Example of statement:</p>
<pre class="txt-code decal"><span class="opt-name">$TBS</span> = new clsTinyButStrong;</pre>
<p>This object allows you to load a template, to handle the merging of it
with data, and then to show the result.</p>
<p> Example of PHP code: </p>
<pre class="txt-code decal">include_once(<span class="opt-value">'tbs_class.php'</span>);
<span class="opt-name">$TBS</span> = new clsTinyButStrong;
<span class="opt-name">$TBS</span>->LoadTemplate(<span class="opt-value">'template.htm'</span>) ;
<span class="opt-name">$TBS</span>->MergeBlock(<span class="opt-value">'ctry','mysql','SELECT * FROM t_country'</span>);
<span class="opt-name">$TBS</span>->Show();</pre>
<p>Here is the description of the TinyButStrong object: </p>
<h3><a id="php_instanciate"></a>create a new TBS object:</h3>
<div class="norm">
<p>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.</p>
<p> Syntax to create a new TBS object as of version 3.8.0: <span class="txt-code"><span
class="opt-name">$TBS</span> = new clsTinyButStrong({<span class="opt-type">array</span>
<span class="opt-name">Options</span>})</span></p>
<table cellspacing="0" cellpadding="5" border="0">
<tbody>
<tr>
<th width="80">Argument</th>
<th>Description</th>
</tr>
<tr>
<td class="opt-name" align="left" valign="top">Options</td>
<td align="left" valign="top">An array of options to set for the
option of the template engine. See all available options at the
<a href="#php_setoption">SetOption</a> section.</td>
</tr>
</tbody>
</table>
<p>Examples:</p>
<pre class="decal txt-code"><span class="opt-name">$TBS1</span> = new clsTinyButStrong; <span
class="opt-html"> // default behavior</span>
<span class="opt-name">$TBS2</span> = new clsTinyButStrong(<span class="opt-value"> array('chr_open'=></span><span
class="opt-value">'{', 'chr_close'=>'}')</span> ); <span class="opt-html">// TBS tags will be like {var.x} instead of [var.x]</span>
<span class="opt-name">$TBS3</span> = new clsTinyButStrong(<span class="opt-value"> array('var_prefix'=></span><span
class="opt-value">'tbs_fct_')</span> );<span class="opt-html"> // TBS will display only PHP global variables beginning with 'tbs_var_</span>'
<span class="opt-name">$TBS4</span> = new clsTinyButStrong(<span class="opt-value"> array('fct_prefix'=></span><span
class="opt-value">'tbs_fct_') </span>);<span class="opt-html"> // TBS will call only PHP function beginning with 'tbs_fct_'</span></pre>
<div class="versioning">
<p>Versioning:</p>
<p>Before TBS version 3.8.0, the syntax to create a new TBS object
was:<br>
<span class="txt-code"><span class="opt-name">$TBS</span>
= new clsTinyButStrong({string <span class="opt-name">chr_delim</span>
{, string <span class="opt-name">var_prefix</span> {, string <span
class="opt-name">fct_prefix</span>}}});</span><br>
where: </p>
<ul class="list-mini">
<li><span class="opt-name"> chr_delim</span> is the concatenation of
(the option <a href="#php_setoption_chr_open" class="opt-name">chr_open</a>
+ the string ',' + the option <a href="#php_setoption_chr_close"
class="opt-name">chr_close</a>). For example: '{,}'</li>
<li><span class="opt-name">var_prefix</span> is the value for the
option <a href="#php_setoption_var_prefix" class="opt-name">var_prefix</a></li>
<li><span class="opt-name">fct_prefix</span> is the value for the
option <a href="#php_setoption_fct_prefix" class="opt-name">fct_prefix</a></li>
</ul>
</div>
<h3><a id="php_loadtemplate"></a>method LoadTemplate():</h3>
<div class="norm">
<p>Loads a template for the merging process. The complete contents of
the file is immediately stored in the <a href="#php_source">Source</a>
property of the TBS object, then [onload] <a href="#html_field_auto">fields</a>
and <a href="#html_block_auto">blocks</a> are merged. If the file
is not found, then it will also be searched in the folder of the
last loaded template (<span class="versioning">since TBS version
3.2.0</span>).</p>
<p> Syntax: <span class="txt-code"><span class="opt-name">$TBS</span>->LoadTemplate(<span
class="opt-type">string</span> <span class="opt-name">File </span><span
class="opt-name"><span style="color:#333333">[</span></span>, <span
class="opt-type">string</span><span class="opt-name"> Charset <span
class="opt-value"> = ''</span><span style="color:#333333">]</span></span>)</span>
</p>
<table cellspacing="0" cellpadding="5" border="0">
<tbody>
<tr>
<th>Argument</th>
<th>Description</th>
</tr>
<tr>
<td class="opt-name" align="left" valign="top">File</td>
<td align="left" valign="top">Local or absolute path of the file
to load.<br>
This value can be <span class="opt-value">null</span> or <span
class="opt-value">''</span> (empty string) for special
actions. See below for more details. </td>
</tr>
<tr>
<td class="opt-name" align="left" valign="top">Charset</td>
<td align="left" valign="top">
<p>Optional. Will set the <a href="#php_setoption_charset" class="opt-name">charset</a>
option.</p>
</td>
</tr>
</tbody>
</table>
<h4>Scope of the file path:</h4>
<p>If the file is not found then its' also searched into the directory
of the last loaded template, or the last loaded subtemplate.</p>
<p> <span class="versioning">Since TBS version 3.3.0</span>, the file
also searched into the <a href="http://www.php.net/manual/en/ini.core.php#ini.include-path">include_path</a>.</p>
<h4>Adding the file at the end of the current template:</h4>
<p>You can use the keyword <span class="opt-value">'+'</span> for the
argument <span class="opt-name">Charset</span> to have the file
defined by <span class="opt-name">File</span> added to the end of
the current template. The current charset will not be modified.</p>
<h4>Special actions using argument File:</h4>
<p><span class="versioning">Since TBS version 3.4.0.<br>
</span> If <span class="opt-name">File</span> is <span class="opt-value">null</span>,
then all default actions (Plug-ins, [onload] tags, and Charset) are
applied without loading any file. <br>
If <span class="opt-name">File</span> is <span class="opt-value">''</span>
(empty string), then only the <a href="#php_setoption_charset" class="opt-name">charset</a>
option is modified, without doing any other action. (deprecated
since TBS version 3.8.0, use <a href="#php_setoption">SetOption()</a>
instead)<br>
In both cases, if <span class="opt-name">Charset</span> is <span class="opt-value">'+'</span>,
then it will be ignored and the current charset will not be
modified.</p>
<p> Example:</p>
<pre class="decal txt-code"><span class="opt-name">$TBS</span>->Source = <span
class="opt-name">$template</span>; <span class="opt-html">// load the template from a string</span>
<span class="opt-name">$TBS</span>->LoadTemplate(<span class="opt-value">null</span>,<span
class="opt-value">'BIG5'</span>); <span class="opt-html">// run plug-ins if any, and merges [onload] tags if any</span>
...
<span class="opt-name">$TBS</span>->LoadTemplate(<span class="opt-value">''</span>,<span
class="opt-value">false</span>); <span class="opt-html">// turn the charset to no-charset</span></pre>
</div>
<h3><a id="php_mergeblock"></a>method MergeBlock():</h3>
<div class="norm">
<p>Merges one or several <a href="#html_block">TBS blocks</a> with
records coming from a data source.</p>
<p>By default, this method returns the number of merged records (more
exactly, it is the number of the last record), but it can also
return the full merged record set (see argument <span class="opt-name">BlockName</span>).</p>
<p><span class="versioning">Versioning: since TBS version 3.12.0,
MergeBlock() return false if no block and no field have been
merged. Before that it returned 0.</span></p>
<p>TinyButStrong supports several data source types in native:</p>
<table cellspacing="0" cellpadding="5" border="0">
<tbody>
<tr>
<th>Php data:</th>
<td>an array, a string, a number, an IteratorAggregate</td>
</tr>
<tr>
<th>PHP Databases Drivers:</th>
<td>MySQL, PostgreSQL, SQLite, PDO<br>
</td>
</tr>
<tr>
<td>PHP Library Connectors:</td>
<td>Doctrine DBAL, Zend_Db</td>
</tr>
</tbody>
</table>
<p> You can also add a new one: '<a href="#plugins_db">database
plug-ins</a>'.</p>
<p> Syntax: <span class="txt-code"><span class="opt-type">mixed</span><span
class="opt-name"></span> <span class="opt-name">$TBS</span>->MergeBlock(<span
class="opt-type">string</span><span class="opt-name"> BlockName</span>,
<span class="opt-type">mixed</span> <span class="opt-name">Source<span
style="color:#333333"> [</span></span>, <span class="opt-type">string</span><span
class="opt-name"> Query <span class="opt-value">= ''</span> <span
style="color:#333333">[, <span class="opt-type">mixed</span>
QryPrms = false]]</span></span>)</span> </p>
<table cellspacing="0" cellpadding="5" border="0">
<tbody>
<tr>
<th>Argument</th>
<th>Description</th>
</tr>
<tr>
<td class="opt-name" align="left" valign="top">BlockName</td>
<td align="left" valign="top">Indicates the name of the TBS <a
href="#html_block">block</a> to merge.<br>
You can merge several blocks with the same data by indicating
their names separated by commas.<br>
If you add <span class="opt-value"> '*'</span> as a block
name, then the method will return the full merged record set
as a PHP array, instead of the number of records.
<div class="versioning">Versioning: the keyword '*' is
supported since TBS version 3.0.</div>
</td>
</tr>
<tr>
<td class="opt-name" align="left" valign="top">Source</td>
<td align="left" valign="top">
<p>Indicates the data source to merge.<br>
The table below shows the possible values according to the
data source type.</p>
</td>
</tr>
<tr>
<td class="opt-name" align="left" valign="top">Query</td>
<td align="left" valign="top"> Optional. Indicates the SQL
statement which returns the records to merge.<br>
The table below shows the possible values according to the
data source type.</td>
</tr>
<tr>
<td class="opt-name" align="left" valign="top">QryPrms</td>
<td align="left" valign="top">Optional. Extra parameters for the
query. Few data source types are taking this argument in
account.<br>
<div class="versioning">Versioning: the argument QryPrms is
supported since TBS version 3.7.0.</div>
</td>
</tr>
</tbody>
</table>
<h4>Link between the block and the records:</h4>
<div class="decal">
<p>The MergeBlock() method searches in your template for the
specified TBS block name. Then, the block is repeated as many
times as there are records in the data source. </p>
<p> To display the data of a record, you have to use a linked TBS
Field. A TBS Field is linked when the name of it is composed of
the block's name followed by a dot and a column's or a key's name
in the record set. A linked field must be inside the block.</p>
<p> Example: </p>
<table class="decal">
<tbody>
<tr>
<td>Block's name: </td>
<td><span class="opt-value">block1</span></td>
</tr>
<tr>
<td>Columns returned by the query:</td>
<td><span class="opt-value">column1</span>,<span class="opt-value">
column2, </span><span class="opt-value">column3</span></td>
</tr>
<tr>
<td>Linked TBS Fields:</td>
<td><span class="opt-value">[block1.column1]</span>, <span class="opt-value">[block1.column2]</span>,
<span class="opt-value">[block1.column3]</span></td>
</tr>
</tbody>
</table>
<p>If no block's definition is found in the template (that is
parameter <a class="opt-name" href="#html_field_prm_block">block</a>
is never used on the block's fields), then the MergeBlock() method
will merge the first record with all linked fields found in the
template.</p>
<p> You can also define more advanced blocks. For more information,
refer to chapter <a href="#html_block">TBS Blocks</a>.</p>
</div>
<h4><a id="php_mergeblock_subnames"></a>Merging subnames</h4>
<div class="decal">
<p>In a TBS field, you can refer to an array item, a method or a
property using subnames:</p>
<table class="decal">
<tbody>
<tr>
<td>An item of an array</td>
<td><span class="opt-value">[block1.arr1.key1]</span></td>
</tr>
<tr>
<td>A property of an object:</td>
<td><span class="opt-value">[block1.obj1.propZ]</span></td>
</tr>
<tr>
<td>A method of an object</td>
<td><span class="opt-value">[block1.obj1.methA()]</span></td>
</tr>
<tr>
<td>A method of an object with argument :</td>
<td><span class="opt-value">[block1.obj1.methA(arg1)]</span></td>
</tr>
<tr>
<td>Cascading subnames:</td>
<td><span class="opt-value">[block1.arr1.key2.methA().PropZ]</span></td>
</tr>
</tbody>
</table>
<p>This assumes the parent's name of a subname refers to an array or
an object.</p>
<p>Remarks :</p>
<ul>
<li>Using lot of subnames can decrease performance since the
parsing is <span title="">reassessed</span> on each record.</li>
<li>Don't merge data having objects with methods that should not
be called from a template. Because the template builder could
invoke them erroneously.</li>
</ul>
</div>
<h4><a id="php_mergeblock_mergeseveral"></a>Merging several blocks
with the same data:</h4>
<div class="decal">
<p>You can merge several blocks with the same data by indicating
their names separated by commas in the <span class="opt-name">BlockName</span>
parameter. In this case, the query is opened only one time, and
records are buffered to feed blocks.</p>
<p> Example: <span class="opt-name"><span class="txt-code">$TBS</span></span><span
class="txt-code">->MergeBlock(<span class="opt-value">'block1,block2,block3'</span>,<span
class="opt-value">'mysql'</span>,<span class="opt-value">'SELECT
* FROM MyTable'</span>);</span></p>
<p> You cannot merge several blocks having the same names because
they are considered by TBS has a one and only block composed of
several sections. Nevertheless, you can use a tip to get a similar
behavior. If you use parameter <a href="#html_block_prm_p1" class="opt-name">p1</a>
without value in the block definition, that does forces TBS to
consider the section as a new block break, like it does for <a href="#html_block_dynsb">subblocks</a>.</p>
<p> Example: </p>
<div class="decal">
<table cellspacing="5" cellpadding="0" border="0">
<tbody>
<tr>
<td>
<table cellspacing="0" cellpadding="1" border="1">
<tbody>
<tr style="font-weight:bold; background-color: #66CCFF;">
<td>Id</td>
<td>Name</td>
</tr>
<tr>
<td>[b.id;block=tr;p1]</td>
<td>[b.name]</td>
</tr>
</tbody>
</table>
</td>
<td>
<table cellspacing="0" cellpadding="1" border="1">
<tbody>
<tr style="font-weight:bold; background-color: #FFCC66;">
<td>Id</td>
<td>Name</td>
</tr>
<tr>
<td>[b.id;block=tr;p1]</td>
<td>[b.name]</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p class="txt-code"><span class="opt-name"><span class="txt-code">$TBS</span></span>->MergeBlock(<span
class="opt-value">'b'</span>,<span class="opt-value">'mysql'</span>,<span
class="opt-value">'SELECT * FROM MyTable'</span>);</p>
</div>
<p class="versioning">Versioning: this tip is available since TBS
version 3.4. </p>
</div>
<h4>Returning the full merged record set:</h4>
<div class="decal">
<p>In some cases, it may be useful for you to retrieve the full
record set after the merge. For that, you simply have to ad the
keyword <span class="opt-value">'*'</span> in the list of block's
names. Use this feature with care, because it save the merged data
in the memory which can take resources.</p>
<p> Example: <span class="opt-name">$data</span> = <span class="opt-name"><span
class="txt-code">$TBS</span></span><span class="txt-code">->MergeBlock(<span
class="opt-value">'block1,*'</span>,<span class="opt-value">'mysql'</span>,<span
class="opt-value">'SELECT * FROM MaTable'</span>);</span></p>
</div>
<h4><a id="php_mergeblock_counting"></a>Counting the records:</h4>
<div class="decal">
<p>To display the number of the record in the template, use a TBS
Field linked to the virtual column '<span class="opt-value">#'</span>.
If you put this field outside the block, it will display the total
number of records.</p>
<p> Example: <span class="opt-value">[block1.#]</span></p>
<p> The virtual column '<span class="opt-value">$'</span> will
display the key of the current record if the data source is a Php
array.</p>
<p> Example: <span class="opt-value">[block1.$]</span></p>
</div>
<h4>Resource and Request arguments according to the data source type:</h4>
<div class="decal">
<table class="border-0" cellspacing="0" cellpadding="2">
<tbody>
<tr style="font-weight:bold; background-color: #B2B2B2;">
<td class="border-0" width="120">Data Source Type</td>
<td class="border-0" width="350">Source</td>
<td class="border-0">Query<span class="txt-code"><span class="opt-name"></span></span></td>
</tr>
<tr valign="top">
<td class="border-0">Assigned <span class="txt-tiny">(*)</span></td>
<td class="border-0">The keyword <span class="opt-value">'assigned'</span>
or omitted</td>
<td class="border-0">-</td>
</tr>
<tr valign="top">
<td class="border-0">Text <span class="txt-tiny">(*)</span></td>
<td class="border-0">The keyword <span class="opt-value">'text'</span></td>
<td class="border-0">A text</td>
</tr>
<tr valign="top">
<td class="border-0">Number <span class="txt-tiny">(*)</span></td>