Smarty template, smarty
Although the smarty template is not very easy to use, we still need to know some of the basics and methods to help us understand the principles of phpcms and learn the tp framework.
The following describes the usage of built-in functions. The first is foreach.
1 foreach is a block function, that is, there are beginning and end, <{foreach}> <{/foreach}>
For example, in the main folder, I created a file named test. php, whose content is
<? Phpinclude (".. /init. inc. php "); $ arr = array (" n001 "," Han "), array (" n002 "," Hui "), array (" n003 ", "Miao") $ smarty-> assign ("arr", $ arr); $ smarty-> display(test.html); // html file created in the template folder
In test.html, it is represented:
<select> <{foreach $arr as $v}> <option><{$v[1]}></option> <{/foreach}></select>
:
<Select> <{foreach $ arr as $ k = >$ v}> <option ><{$ k }><{$ v [1] }></option> here is different, the results are different <{/foreach}> </select>
Is indexed:
2 is a small plug-in about keywords, that is, when the keyword is marked as: modifier. key. php
<?phpfunction smarty_modifier_key($str,$key) { return str_replace($key,"<mark>$key</mark>",$str);}
$ Smarty-> assign; furniture hot and sour home China Branch Shengli Street is annoying to see the other side is considering the Chinese style has reduced the aircraft Scola aircraft ");
<{$ Title | key: "China "}
:
3. textarea tag: a built-in plug-in smarty
<{textarea color="red" toolbar="full"}><{/textarea}>
:
4. Use its built-in plug-in to select and represent the year, month, and day.
<{html_select_date month_format="%m"}>
:
5. Color plug-ins
<{color name="color"}>
:
6. Time Selection plug-in
<{date name="riqi"}>
:
I think these plug-ins may be used later. I just sorted them out to facilitate searching for them.