实例3.
==================================================
example3.tpl
==================================================
<html>
<head><title>模板中内定的一些函数</title></head>
<body>
{*下面的这一段相当于在模板内部定义一个变量UserName*}
{assign var="UserName" value="大师兄"}
这里将显示模板内部定义的一个变量:UserName = {$UserName}
下面的这一行将显示3个checkBox:<br>
{html_checkboxes name="CheckBox" values=$CheckName checked=$IsChecked output=$value separator="<br />"}
下面在这一行将显示3个radio:<br>
{html_radios name="RadioBox" values=$RadioName checked=$IsChecked output=$value separator="<br />"}
下面显示一个月,日, 年选择框:<br>
{html_select_date}
<hr><b>CopyRight© By XiaoJun, Li 2004<b>{mailto address="teacherli@163.ccom" text="联系作者"}
</body>
</html>
======================================================
example3.php
======================================================
<?php
/*********************************************
*
* 文件名: example3.php
* 作 用: 显示实例程序3
*
* 作 者: 大师兄
* Email:
xfz_hd@163.com*
*********************************************/
require_once ("./comm/Smarty.class.php");
$smarty = new Smarty();
$smarty->template_dir = './templates/';
$smarty->compile_dir = './templates_c/';
$smarty->config_dir = './configs/';
$smarty->cache_dir = './cache/';
$smarty->caching = false;
//--------------------------------------------------------------------------------------
//处理{html_checkboxes name="CheckBox" values=$CheckName checked=$IsChecked output=$value separator="<br />"}
//--------------------------------------------------------------------------------------
$smarty->assign('CheckName', array(
1001 => '语文',
1002 => '数学',
1003 => '外语'));
$smarty->assign('IsChecked', 1001);
//--------------------------------------------------------------------------------------
//处理{html_radioes name="RadioBox" values=$RadioName checked=$IsChecked output=$value separator="<br />"}
//--------------------------------------------------------------------------------------
$smarty->assign('RadioName', array(
1001 => '语文',
1002 => '数学',
1003 => '外语'));
$smarty->assign('IsChecked', 1001);
//--------------------------------------------------------------------------------------
//{html_select_date}不用处理会自动输出
//--------------------------------------------------------------------------------------
$smarty->display("example3.tpl");
?>
======================================================
example3.php输出效果:
======================================================
<html>
<head><title>模板中内定的一些函数</title></head>
<body>
{assign var="UserName" value="大师兄"}
这里将显示模板内部定义的一个变量:UserName = 大师兄
下面的这一行将显示3个checkBox:<br>
<input type="checkbox" name="CheckBox[]" value="1000">语文<br />
<input type="checkbox" name="CheckBox[]" value="1001" checked="checked">数学<br />
<input type="checkbox" name="CheckBox[]" value="1002">外语<br />
下面在这一行将显示3个radio:<br>
<input type="radio" name="RadioBox[]" value="1000">语文<br />
<input type="radio" name="RadioBox[]" value="1001" checked="checked">数学<br />
<input type="radio" name="RadioBox[]" value="1002">外语<br />
下面显示一个月,日, 年选择框:<br>
<select name="Date_Month">
<option label="January" value="01">January</option>
<option label="February" value="02">February</option>
<option label="March" value="03">March</option>
<option label="April" value="04">April</option>
<option label="May" value="05">May</option>
<option label="June" value="06">June</option>
<option label="July" value="07">July</option>
<option label="August" value="08" selected="selected">August</option>
<option label="September" value="09">September</option>
<option label="October" value="10">October</option>
<option label="November" value="11">November</option>
<option label="December" value="12">December</option>
</select>
<select name="Date_Day">
<option label="01" value="1">01</option>
<option label="02" value="2">02</option>
<option label="03" value="3">03</option>
<option label="04" value="4">04</option>
<option label="05" value="5">05</option>
<option label="06" value="6">06</option>
<option label="07" value="7">07</option>
<option label="08" value="8">08</option>
<option label="09" value="9">09</option>
<option label="10" value="10">10</option>
<option label="11" value="11">11</option>
<option label="12" value="12">12</option>
<option label="13" value="13">13</option>
<option label="14" value="14">14</option>
<option label="15" value="15">15</option>
<option label="16" value="16">16</option>
<option label="17" value="17">17</option>
<option label="18" value="18">18</option>
<option label="19" value="19">19</option>
<option label="20" value="20">20</option>
<option label="21" value="21" selected="selected">21</option>
<option label="22" value="22">22</option>
<option label="23" value="23">23</option>
<option label="24" value="24">24</option>
<option label="25" value="25">25</option>
<option label="26" value="26">26</option>
<option label="27" value="27">27</option>
<option label="28" value="28">28</option>
<option label="29" value="29">29</option>
<option label="30" value="30">30</option>
<option label="31" value="31">31</option>
</select>
<select name="Date_Year">
<option label="2004" value="2004" selected="selected">2004</option>
</select>
<hr><b>CopyRight© By XiaoJun, Li 2004<b><a href="mailto:teacherli@163.com">ÁªÏµ×÷Õß</a>
</body>
</html>
例3使用了一些smarty模板中内置的一些函数,相似的函数大家可以在手册中查到,使用方法很简单,大家可以自己去查找.