summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/pages/Configurations/Templates2.page
blob: 66d9d0d1fabf796b34d9e5a5b2d89ca49d322cbd (plain)
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
<com:TContent ID="body" >
<h1>Templates: Part II</h1>

<a name="dct" />
<h2>Dynamic Content Tags</h2>
<p>
Dynamic content tags are introduced as shortcuts to some commonly used <a href="?page=Configurations.Templates1#ct">component tags</a>. These tags are mainly used to render contents resulted from evaluating some PHP expressions or statements. They include <a href="#et">expression tags</a>, <a href="#st">statement tags</a>, <a href="#dt">databind tags</a>, <a href="#pt">parameter tags</a> and <a href="#at">asset tags</a>.
</p>

<a name="et" />
<h3>Expression Tags</h3>
<p>
An expression tag represents a PHP expression that is evaluated when the template control is being rendered. The expression evaluation result is inserted at the place where the tag resides in the template. Its format is as follows,
<com:TTextHighlighter Language="prado" CssClass="source">
&lt;%= PhpExpression %&gt;
</com:TTextHighlighter>
Inernally, an expression tag is represented by a <tt>TExpression</tt> control. Therefore, in the expression <tt>$this</tt> refers to the <tt>TExpression</tt> control. For example, the following expression tag will display the current page title at the place,
<com:TTextHighlighter Language="prado" CssClass="source">
&lt;%= $this-&gt;Page-&gt;Title %&gt;
</com:TTextHighlighter>
</p>

<a name="st" />
<h3>Statement Tags</h3>
<p>
Statement tags are similar to expression tags, except that statement tags contain PHP statements rather than expressions. The output of the PHP statements (using for example <tt>echo</tt> or <tt>print</tt> in PHP) are displayed at the place where the statement tag resides in the template. Inernally, a statement tag is represented by a <tt>TStatements</tt> control. Therefore, in the statements <tt>$this</tt> refers to the <tt>TStatements</tt> control. The format of statement tags is as follows,
<com:TTextHighlighter Language="prado" CssClass="source">
&lt;%%
PHP Statements
%&gt;
</com:TTextHighlighter>
</p>
<p>
The following example displays the current time in Dutch at the place,
<com:TTextHighlighter Language="prado" CssClass="source">
&lt;%%
setlocale(LC_ALL, 'nl_NL');
echo strftime("%A %e %B %Y",time());
%&gt;
</com:TTextHighlighter>
</p>

<a name="dt" />
<h3>Databind Tags</h3>
<p>
Databind tags are similar to expression tags, except that the expressions are evaluated only when a <tt>dataBind()</tt> call is invoked on the controls representing the databind tags. Internally, a <tt>TLiteral</tt> control is used to represent a databind tag and <tt>$this</tt> in the expression would refer to the control. The format of databind tags is as follows,
<com:TTextHighlighter Language="prado" CssClass="source">
&lt;%# PhpExpression %&gt;
</com:TTextHighlighter>
</p>

<a name="pt" />
<h3>Parameter Tags</h3>
<p>
Parameter tags are used to insert application parameters at the place where they appear in the template. The format of parameter tags is as follows,
<com:TTextHighlighter Language="prado" CssClass="source">
&lt;%$ ParameterName %&gt;
</com:TTextHighlighter>
Note, application parameters are usually defined in application configurations or page directory configurations. The parameters are evaluated when the template is instantiated.
</p>

<a name="at" />
<h3>Asset Tags</h3>
<p>
Asset tags are used to publish private files and display the corresponding the URLs. For example, if you have an image file that is not Web-accessible and you want to make it visible to end-users, you can use asset tags to publish this file and show the URL to end-users so that they can fetch the published image.
</p>
<p>
The format of asset tags is as follows,
<com:TTextHighlighter Language="prado" CssClass="source">
&lt;%~ LocalFileName %&gt;
</com:TTextHighlighter>
where <tt>LocalFileName</tt> refers to a file path that is relative to the directory containing the current template file. The file path can be a single file or a directory. If the latter, the content in the whole directory will be made accessible by end-users.
</p>
<p>
BE VERY CAUTIOUS when you are using asset tags as it may expose to end-users files that you probably do not want them to see.
</p>

</com:TContent>