When using smarty to call the CSS & Javascript file using relative paths in the TPL file, the reference object of this relative path is actually written by calling the PHP file of the TPL file.
If I call template/index. TPL in the index. php file, the relative path of CSS & Javascript file used in index. TPL is relative to index. php.
The path of these files.
Display usage:
// From PHP script, for Linux
$ Smarty-> display ("file:/export/templates/index. TPL ");
$ Smarty-> display ("file:/path/to/My/templates/menu. TPL ");
// From PHP script, for Windows
$ Smarty-> display ("file: C:/export/templates/index. TPL ");
$ Smarty-> display ("file: F:/path/to/My/templates/menu. TPL ");
Include usage:
{Include file = "template storage path "}
// From within smarty template, for Windows & for Linux
{Include file = "file: D:/usr/local/share/templates/navigation. TPL "}
{Include file = "file =" file:/usr/local/share/templates/navigation. TPL "}
Foreach usage:
{Foreach [name = "The Name Of The foreach loop for accessing foreach properties"] From = "the name of the array you are looping through" item = "the name of the variable that is current element "}
......
{/Foreach}
You can also use $ smarty. foreach. foreachname. varname to access the attributes of foreach. foreachname indicates the name attribute value specified in foreach;
Varname:
Iteration (iteration is used to display the current loop iteration, iteration always starts with 1 and incremented by one each iteration );
First (first is set to true if the current foreach iteration is the first one );
Last (last is set to true if the current foreach iteration is the last one );
Show (show is used as a parameter to foreach. show is a Boolean value, true or false. if false, the foreach will not be displayed. if there is a foreachelse present, that will be alternately displayed .);
Total (total is used to display the number of iterations that this foreach will loop. This can be used inside or after the foreach .)