forked from tbelliard/gepi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tbs_us_manual.htm
executable file
·4103 lines (4083 loc) · 317 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>
<title>TBS Manual</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<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: 8;
margin-bottom: 6;
}
h5 {
font-weight: bold;
font-size: 12px;
margin-top: 3;
margin-bottom: 3;
}
h6 {
text-decoration: underline;
font-weight:normal;
font-size: 12px;
margin-top: 8;
margin-bottom: 6;
}
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:4;
}
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;
border: thin solid #00EC9F;
padding: 2px;
margin-top: 3px;
margin-left: 20px;
}
-->
</style>
</head>
<body bgcolor="#FFFFFF">
<div id="main-body">
<div class="txt-tiny" style="display:inline-block; float:left;">
<table class="txt-tiny" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50">Site:</td>
<td><a href="http://www.tinybutstrong.com" target="_top">www.tinybutstrong.com</a></td>
</tr>
<tr>
<td>Authors:</td>
<td><a href="http://www.tinybutstrong.com/onlyyou.html">skrol29</a>, Pirjo</td>
</tr>
<tr>
<td>Date:</td>
<td>2019-02-07</td>
</tr>
</table>
</div>
<div style="margin:auto; width:500px; text-align:center;">
<h1>TinyButStrong Documentation</h1>
<div class="txt-tiny">version 3.11</div>
<div style="margin-top:10px;">Template Engine for Pro and Beginners<br>
for PHP 5 and 7</div>
</div>
<h2>Table of Contents:</h2>
<div class="norm">
<table border="0" cellspacing="0">
<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_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>
</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 name="principles" 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 name="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 name="examples" id="examples"></a>Mini examples:</h3>
<p>Example 1: </p>
<table border="0" cellpadding="2" cellspacing="4">
<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>
</table>
<p>Example 2: </p>
<table border="0" cellpadding="2" cellspacing="4">
<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>
</table>
<a name="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 name="php_instanciate" 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 border="0" cellpadding="5" cellspacing="0">
<tr>
<th width="80">Argument</th>
<th>Description</th>
</tr>
<tr>
<td align="left" valign="top" class="opt-name">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>
</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 name="php_loadtemplate" 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 border="0" cellpadding="5" cellspacing="0">
<tr>
<th>Argument</th>
<th>Description</th>
</tr>
<tr>
<td align="left" valign="top" class="opt-name">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 align="left" valign="top" class="opt-name">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>
</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 name="php_mergeblock" 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.
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>TinyButStrong supports several data source types in native:</p>
<table border="0" cellpadding="5" cellspacing="0">
<tr>
<th>Php data:</th>
<td>an array, a string, a number</td>
</tr>
<tr>
<th width="80">Databases:</th>
<td>MySQL ; PostgreSQL ; SQLite</td>
</tr>
</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">int</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 border="0" cellpadding="5" cellspacing="0">
<tr>
<th>Argument</th>
<th>Description</th>
</tr>
<tr>
<td align="left" valign="top" class="opt-name">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. 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 align="left" valign="top" class="opt-name">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 align="left" valign="top" class="opt-name">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 align="left" valign="top" class="opt-name">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>
</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">
<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> </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 name="php_mergeblock_subnames" id="php_mergeblock_mergeseveral3"></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">
<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>
</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 name="php_mergeblock_mergeseveral" 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 border="0" cellspacing="5" cellpadding="0">
<tr>
<td><table border="1" cellspacing="0" cellpadding="1">
<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>
</table></td>
<td><table border="1" cellspacing="0" cellpadding="1">
<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>
</table></td>
</tr>
</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 name="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 cellpadding="2" cellspacing="0" class="border-0">
<tr style="font-weight:bold; background-color: #B2B2B2;">
<td width="120" class="border-0">Data Source Type</td>
<td width="350" class="border-0">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>
<td class="border-0">The keyword <span class="opt-value">'num'</span></td>
<td class="border-0">A number or a special array (see below)</td>
</tr>
<tr valign="top">
<td class="border-0">Clear<span class="txt-tiny"> (*)</span></td>
<td class="border-0">The keyword <span class="opt-value">'clear'</span></td>
<td class="border-0">-</td>
</tr>
<tr valign="top">
<td class="border-0">Conditional<span class="txt-tiny"> (*)</span></td>
<td class="border-0">The keyword <span class="opt-value">'cond'</span></td>
<td class="border-0">-</td>
</tr>
<tr valign="top">
<td rowspan="3" class="border-0"> PHP Array <span class="txt-tiny">(*)</span></td>
<td class="border-0">A Php array</td>
<td class="border-0">-</td>
</tr>
<tr>
<td valign="top" class="border-0">The keyword <span class="opt-value">'array'</span></td>
<td valign="top" class="border-0">A Php Array</td>
</tr>
<tr>
<td valign="top" class="border-0">The keyword <span class="opt-value">'array'</span></td>
<td valign="top" class="border-0">A string that represents an array contained or nested in a PHP global variable (see below)</td>
</tr>
<tr>
<td class="border-0">PHP <a href="http://www.php.net/manual/en/class.arrayobject.php">ArrayObject</a></td>
<td rowspan="3" valign="top" class="border-0">A PHP object. <span class="versioning">Supported since TBS version 3.5.0.</span></td>
<td rowspan="3" valign="top" class="border-0">-</td>
</tr>
<tr>
<td class="border-0">PHP <a href="http://www.php.net/manual/en/class.iterator.php">Iterator</a></td>
</tr>
<tr>
<td class="border-0">PHP <a href="http://www.php.net/manual/en/class.iteratoraggregate.php">IteratorAggregate</a></td>
</tr>
<tr valign="top">
<td class="border-0">PDO</td>
<td class="border-0">A <a href="http://www.php.net/manual/en/book.pdo.php">PDO</a> object. <span class="versioning">Supported since TBS version 3.7.0.</span></td>
<td class="border-0">An SQL statement. Optional argument <a href="#php_mergeblock" class="opt-name">QryPrms</a> can be used like with <a href="http://www.php.net/manual/en/pdostatement.execute.php">PDOStatement->execute(QryPrms</a>).</td>
</tr>
<tr valign="top">
<td class="border-0">Zend DB Adapter</td>
<td class="border-0">A <a href="http://framework.zend.com/manual/en/zend.db.adapter.html">Zend DB Adapter</a> object. <span class="versioning">Supported since TBS version 3.8.0.</span></td>
<td class="border-0">An SQL statement. Optional argument <a href="#php_mergeblock" class="opt-name">QryPrms</a> can be used like with <a href="http://framework.zend.com/manual/en/zend.db.adapter.html#zend.db.adapter.transactions">$db->execute($sql, $prms</a>).</td>
</tr>
<tr valign="top">
<td class="border-0">MySQLi</td>
<td class="border-0">A <a href="http://www.php.net/manual/en/book.mysqli.php">MySQLi</a> object. <span class="versioning">Supported since TBS version 3.7.0.</span></td>
<td class="border-0">An SQL statement</td>
</tr>
<tr valign="top">
<td rowspan="2" class="border-0">MySQL</td>
<td class="border-0">A <a href="http://www.php.net/manual/en/book.mysql.php">MySql</a> connection identifier or the keyword <span class="opt-value">'mysql'</span></td>
<td class="border-0">An SQL statement</td>
</tr>
<tr>
<td class="border-0">A MySql result identifier</td>
<td class="border-0">-</td>
</tr>
<tr valign="top">
<td rowspan="2" class="border-0">PostgreSQL</td>
<td class="border-0">A <a href="http://www.php.net/manual/en/book.pgsql.php">PostgreSql</a> connection identifier</td>
<td class="border-0">An SQL statement</td>
</tr>
<tr>
<td class="border-0">A PostgreSql result identifier</td>
<td class="border-0">-</td>
</tr>
<tr valign="top">
<td rowspan="2" class="border-0">SQLite</td>
<td class="border-0">An <a href="http://www.php.net/manual/en/book.sqlite.php">SQLite</a> connection identifier</td>
<td class="border-0">An SQLite statement</td>
</tr>
<tr>
<td class="border-0">An SQLite result identifier</td>
<td class="border-0">-</td>
</tr>
<tr valign="top">
<td rowspan="3" class="border-0">SQLite3</td>
<td class="border-0">An <a href="http://php.net/manual/en/class.sqlite3.php">SQLite3</a> object</td>
<td class="border-0">An SQLite statement. You can use the optional argument <a href="#php_mergeblock" class="opt-name">QryPrms</a> in order to <a href="http://php.net/manual/en/sqlite3stmt.bindvalue.php">bind values</a>.<br>
<span class="txt-code">Exemple #1: array("value1", "values2").<br>
Exemple #2: array(':p1'=>"value1", 'p2' => "value2").<br>
Exemple #3: array(':p1'=>array("value1", SQLITE3_TEXT)).</span></td>
</tr>
<tr valign="top">
<td class="border-0">An <a href="http://php.net/manual/en/class.sqlite3stmt.php">SQLite3Stmt</a> object</td>
<td class="border-0">You can use the optional argument <a href="#php_mergeblock" class="opt-name">Query</a> in order to <a href="http://php.net/manual/en/sqlite3stmt.bindvalue.php">bind values</a>. See examples above.</td>
</tr>
<tr valign="top">
<td class="border-0">An <a href="http://php.net/manual/en/class.sqlite3result.php">SQLite3Result</a> object</td>
<td class="border-0">-</td>
</tr>
<tr valign="top">
<td class="border-0">custom<br></td>
<td class="border-0">A keyword, an object or a resource identifier not mentioned in this table.<br>
See the chapter '<a href="#plugins_db">database plug-ins</a>'.</td>
<td class="border-0">An SQL statement or something else.</td>
</tr>
</table>
<p class="txt-tiny">(*) See explanations in the chapter below.</p>
</div>
<h4>Php data sources:</h4>
<div class="decal">
<h5>• Assigned</h5>
<div class="decal">
<p>The argument <span class="opt-name">Source</span> has to be equal to <span class="opt-value">'assigned'</span> or be omitted.
The block is merged with the arguments defined in the property <a href="#php_assigned">Assigned</a>. </p>
<p> Example : <span class="txt-code"><span class="opt-name">$TBS</span>->MergeBlock(<span class="opt-value">'b1'</span>);</span></p>
<p class="versioning">Versioning: the keyword 'assigned' is supported since TBS version 3.5. </p>
</div>
<h5>• Text</h5>
<div class="decal">
<p>The argument <span class="opt-name">Source</span> has to be equal to <span class="opt-value">'text'</span>.
The whole block is replaced by the text (it must be a string) given as the <span class="opt-name">Query</span> argument. No linked Fields are processed except '<span class="opt-value">#'</span> which returns 1, or 0 if <span class="opt-name">Query</span> is an empty string. </p>
<p> Example: <span class="txt-code"><span class="opt-name">$TBS</span>->MergeBlock(<span class="opt-value">'b1'</span>,<span class="opt-value">'text'</span>,<span class="opt-value">'Hello, how are you?'</span>); </span></p>
</div>
<h5> • Number</h5>
<div class="decal">
<p>The argument <span class="opt-name">Source</span> has to be equal to <span class="opt-value"></span> <span class="opt-value">'num'</span>.
The argument <span class="opt-name">Query</span> can be either a number or an array. </p>
<table border="0" cellspacing="0" cellpadding="3">
<tr>
<th>arg Query</th>
<th>Returned Record Set</th>
</tr>
<tr>
<td valign="top">Number:</td>
<td>This number has to be positive or equal to zero. The returned Record Set consists of a column <span class="opt-value">'val'</span> where the value goes from 1 to this number.</td>
</tr>
<tr>
<td valign="top">Array:</td>
<td>This array has to contain a key <span class="opt-value">'min'</span> and a key <span class="opt-value">'max'</span> and eventually a key <span class="opt-value">'step'</span>.<br>
The returned Record Set consists of a column <span class="opt-value">'val'</span> which goes from the <span class="opt-value">'min'</span> value to the <span class="opt-value">'max'</span> value.</td>
</tr>
</table>
<p>Examples:</p>
<pre class="decal"><span class="txt-code"><span class="opt-name">$TBS</span>->MergeBlock(<span class="opt-value">'b1'</span>,<span class="opt-value">'num'</span>,<span class="opt-value">12</span>);</span>
<span class="txt-code"><span class="opt-name">$TBS</span>->MergeBlock(<span class="opt-value">'b2'</span>,<span class="opt-value">'num'</span>,array(<span class="opt-value">'min'</span>=><span class="opt-value">20</span>,<span class="opt-value">'max'</span>=>3<span class="opt-value">0</span>));</span>
<span class="txt-code"><span class="opt-name">$TBS</span>->MergeBlock(<span class="opt-value">'b3'</span>,<span class="opt-value">'num'</span>,array(<span class="opt-value">'min'</span>=><span class="opt-value">10</span>,<span class="opt-value">'max'</span>=><span class="opt-value">20</span>,<span class="opt-value">'step'</span>=><span class="opt-value">2</span>));</span></pre>
</div>
<h5>• Clear</h5>
<div class="decal">
<p>The argument <span class="opt-name">Source</span> has to be the keyword <span class="opt-value">'clear'</span>.
All blocks and sections are deleted. It is the same thing as merging with an empty array. </p>
<p> Example: <span class="txt-code"><span class="opt-name">$TBS</span>->MergeBlock(<span class="opt-value">'b1'</span>,<span class="opt-value">'clear'</span>); </span></p>
</div>
<h5>• Conditional</h5>
<div class="decal">
<p>The argument <span class="opt-name">Source</span> has to be the keyword<span class="opt-value">'cond'</span>.
The block is merged like it was a <span class="opt-name"> <a href="#html_conditional_section">conditional blocks</a> onload</span> and <span class="opt-name">onshow</span>. The block is not merged with data, and so it must have no linked TBS field. Each block section needs a parameter <span class="opt-name">when</span> or a parameter <span class="opt-name">default</span>. See <a href="#html_conditional_section">conditional blocks</a> for more details. </p>
<p> Example: <span class="txt-code"><span class="opt-name">$TBS</span>->MergeBlock(<span class="opt-value">'bz'</span>,<span class="opt-value">'cond'</span>);</span></p>
</div>
<h5><a name="php_mergeblock_array" id="php_mergeblock_mergeseveral2"></a>• Array</h5>
<div class="decal">
<p>The argument <span class="opt-name">Source</span> has to be a PHP Array or the keyword <span class="opt-value">'array'</span>. If you use the keyword <span class="opt-value">'array'</span>, then the argument <span class="opt-name">Query</span> has to be a Php Array or a string that represents an array contained or nested in <a href="#php_varref">VarRef</a> or <a href="#php_objectref">ObjectRef</a>.</p>
<p> Syntax when <span class="opt-name">Query</span> is a string:</p>
<ul>
<li> <span class="opt-value txt-code">'varref_key[key1]->PropZ[key2]->methA()[key3]...'</span><br>
or</li>
<li><span class="opt-value txt-code">'~objref_key[key1]->PropZ[key2]->methA()[key3]...'</span></li>
</ul>
<p>In the first syntax, <span class="opt-value txt-code">'varref_key'</span> is a key under <span class="txt-code"><span class="opt-name">$TBS</span>->VarRef</span>. (Thus VarRef must be an associated array). By default <span class="txt-code">$TBS->VarRef</span> is a reference on <span class="opt-name">$GLOBAL</span>. See property <a href="#php_varref">VarRef</a> for more details.<br>
In the second syntax, <span class="opt-value txt-code">'objref_key'</span> is a key under <span class="txt-code"><span class="opt-name">$TBS</span>->ObjectRef</span>. (Thus ObjectRef must be an associated array). See property <a href="#php_objectref">ObjectRef</a> for more details.<br>
Sub items like [key] represents a key assuming the previous item is an associative array.<br>
Sub items like <span class="opt-value txt-code">->methA()</span> represents a method assuming the previous item is an object. You can use argments ; for example : <span class="opt-value txt-code">->methA(arg1)</span><br>
Sub items like <span class="opt-value txt-code">->PropZ</span> represents a property assuming the previous item is an object.<br>
</p>
<p>The final item must be an array.</p>
<p> Example: </p>
<pre class="decal txt-code"><span class="opt-name">$TBS</span>->MergeBlock(<span class="opt-value">'block1'</span>,<span class="opt-value">'array'</span>,<span class="opt-value">'days[mon]'</span>);</pre>
<div class="decal txt-small">This will merge 'block1' with the value $day['mon'] assuming it is an array. </div>
<p>It is possible to represent variable's name without items.</p>
<p> Example: </p>
<pre class="decal"> <span class="txt-code"><span class="opt-name">$TBS</span>->MergeBlock(<span class="opt-value">'block1'</span>,<span class="opt-value">'array'</span>,<span class="opt-value">'days'</span>);</span></pre>
<p>There are two advantages in using a string to represent the array:</p>
<ul>
<li> Items will be read directly in the Array (assigned by reference) instead of reading a copy of the items. This can improve the performance.</li>
<li> You can use dynamic queries. </li>
</ul>
<h6>Displaying the key of current record:</h6>
<p>You can use the virtual column '<span class="opt-value">$'</span> which will display the key of the current record. This can be useful especially for <a href="#html_block_dynsb">subblocks with dynamic queries</a>. </p>
<p>Example: [block1.$]</p>
<h6>Structure of supported arrays: </h6>
<p> Items of the specified Array can be of two kinds: simple values with associated keys (case 1), or array values for whom items are themselves simple values with associated keys (case 2).</p>
<p> Case 1: </p>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="80" valign="top">Example: </td>
<td valign="top"><pre>['key1']=>value1
['key2']=>value2
...</pre></td>
</tr>
</table>
<p>The returned Record Set consists of a column <span class="opt-value">'key'</span> containing the name of the key, and a column <span class="opt-value">'val'</span> containing the value of the key. </p>
<p> Case 2: </p>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="80" valign="top">Example: </td>
<td valign="top"><pre>[0] => (['column1']=>value1-0 ; ['column2']=>value2-0 ; ...)
[1] => (['column1']=>value1-1 ; ['column2']=>value2-1 ; ...)
[2] => (['column1']=>value1-2 ; ['column2']=>value2-2 ; ...)
...</pre></td>
</tr>
</table>
<p>The returned Record Set consists of the columns <span class="opt-value">'column1'</span>, <span class="opt-value">'column2'</span>,... with their associated values. </p>
</div>
</div>
</div>
<h3><a name="php_show" id="php_show"></a>method Show():</h3>
<div class="norm">
<p>Terminates the merge. </p>
<p> Syntax: <span class="txt-code"><span class="opt-name">$TBS</span>->Show([<span class="opt-type">int</span><span class="opt-name"> </span><span class="opt-name">Render</span><span class="opt-name"></span><span class="opt-name"><span style="color:#333333"> = false]</span></span>)</span></p>
<p> The Show() method performs the following actions:</p>
<ol>
<li> Merge [onshow] <a href="#html_field_auto">fields</a> and <a href="#html_block_auto">blocks</a>,</li>
<li>Merge [var] <a href="#html_field_auto">fields</a> (for compatibility with version prior to 3.2.0), </li>
<li> Display the result (this action can be cancelled by defining another <a href="#php_setoption_render">Render</a> in the options or in the argument),</li>
<li> End the script (this action can be cancelled by defining another <a href="#php_setoption_render">Render</a> in the options or in the argument).</li>
</ol>
<p> The <a href="#php_setoption_render">Render</a> allows to adjust the behavior of the Show() method. See the <a href="#php_setoption_render">Render</a> option for more information.</p>
</div>
<h3><a name="php_getblocksource" id="php_getblocksource"></a>method GetBlockSource():</h3>
<div class="norm">
<p>Returns the source of a TBS Block from the template.
If no block is found, the method returns <span class="txt-code"><em><span style="color:#0033CC">false</span></em></span>.</p>
<p> Syntax: <span class="txt-code"><span class="opt-type">string</span> <span class="opt-name"></span><span class="opt-name">$TBS</span>->GetBlockSource(<span class="opt-type">string </span><span class="opt-name">BlockName </span>[,<span class="opt-type"> boolean</span> <span class="opt-name">AsArray</span> = <span class="opt-value">false</span> [,<span class="opt-type"> boolean</span> <span class="opt-name">DefTags <span class="opt-value">= true</span> </span>[,<span class="opt-type"> mix</span> <span class="opt-name">ReplaceWith</span> = <span class="opt-value">false</span>]]])</span></p>
<table border="0" cellpadding="5" cellspacing="0">
<tr>
<th>Argument</th>
<th>Description</th>
</tr>
<tr>
<td align="left" valign="top" class="opt-name">BlockName</td>
<td align="left" valign="top">The name of the block to search for.<br></td>
</tr>
<tr>
<td align="left" valign="top" class="opt-name">AsArray</td>
<td align="left" valign="top">Optional. The default value is <span class="txt-code"><em><span style="color:#0033CC">false</span></em></span>. If this parameter is <span class="txt-code"><em><span style="color:#0033CC">true</span></em></span> the method returns the source of the block as a PHP array instead of a string. If the result is an array, then each sections of the block is saved as an item. First item is index 1.</td>
</tr>
<tr>
<td align="left" valign="top" class="opt-name">DefTags</td>
<td align="left" valign="top">Optional. The default value is<span class="txt-code"><em><span style="color:#0033CC"> true</span></em></span>. By default, the method GetBlockSource() returns the source of the block including its definition tags. If you'd like those tags to be deleted, then force the argument <span class="opt-name">DefTags</span> to <em><span style="color:#0033CC">false</span></em>. If the block is defined with a <a href="#html_block">simplified syntax</a> then the definition tags will not be deleted anyway because they are also Field tags.<br>
<p class="versioning">Versioning: this argument is supported since TBS version 3.0.</p></td>