Smarty technology learning and a bit of experience in modifying php templates. Smarty is the best name. it is used. the configuration syntax is Cainiao-level. if you do not have it, first list the one I used: {foreachkeykeyitemMMSPANfrom $ TSortUrl} tdalignleftvalignbottomhei smarty, the configuration syntax is at the Cainiao level. if you do not have it, first list the items I used:
<{Foreach key = key item = MMSPAN from = $ TSortUrl}>
<{If $ mysort eq $ key}>
Img src = "images/sort _ <{$ key}> _ 1.gif" height =" 25 "border =" 0 "/>
<{Else}>
">. Gif" height = "25" border = "0"/>
<{/If}>
<{/Foreach}>
If the template requires dynamic replacement, such as user login information, the best thing is
Call js
The main parameter configurations are as follows:
Include_once (IncludeFile. "/libs/Smarty. class. php ");
$ Tpl = new Smarty ();
$ Tpl-> caching = false; // True
// $ Tpl-> compile_check = true; // after confirmation, the template will not be compiled and changed to false.
$ Tpl-> template_dir = IncludeFile. "/templates/". Isite_tpl ."/";
$ Tpl-> compile_dir = IncludeFile. "/templates_c /";
$ Tpl-> config_dir = IncludeFile. "/configs /";
$ Tpl-> cache_dir = IncludeFile. "/cache /";
$ Tpl-> left_delimiter = <{;
$ Tpl-> right_delimiter =}>;
/*
Two common methods
Template_exists ($ f)To check whether the $ f template exists. Fetch () is used to return the output file of the template that has been signed by assign. it is useful when generating static pages.
Let's take a look at the description of smarty's own chm file. in addition to the basic syntaxes, it depends on your flexible use:
Parameter passing:
<{Include file = "SiteAllTop.html" mysort = "0"}>
Obtain system parameters:
<{If $ MMSPAN [0] eq $ smarty. get. s}> selected <{/if}>
Clear all html formats:
<{$ OReDetail [6] | strip_tags}>
Note: {* Smarty *}
{* Include the header file here *}
{Include file = "header. tpl "}
Mathematical Operators and truncation:
{$ Foo | truncate: "'$ fooTruncCount/$ barTruncFactor-1 '"}
Date format: {$ smarty. now | date_format}
{$ Smarty. now | date_format: "% A, % B % e, % Y "}
{$ Smarty. now | date_format: "% H: % M: % S "}
{$ Yesterday | date_format}
{$ Yesterday | date_format: "% A, % B % e, % Y "}
{$ Yesterday | date_format: "% H: % M: % S "}
OUTPUT:
Feb 6, 2001
Tuesday, February 6, 2001
14:33:00
Feb 5, 2001
Monday, February 5, 2001
14:33:00
Regular expression: {* use spaces to replace each carriage return, tab, and line feed *}
{$ ArticleTitle}
{$ ArticleTitle | regex_replace: "/[]/": ""}
Format string:
{Textformat wrap = 40 indent = 4}
Date Comparison example:<{If $ smarty. now | date_format: "% Y-% m-% d" eq $ MMSPAN [4] | date_format: "% Y-% m-% d"}>
<{/If}>
Else {foreachkey = keyitem = MMSPANfrom = $ TSortUrl} tdalign = "left" valign = "bottom" hei...