这个很简单,举个例子说明一下:
有两个
模板文件:
一、--table.tpl--
复制内容到剪贴板
代码:
<html>
<head>
</head>
<body>
<p align="center"><strong><font color="#FF0000" size="5"></font></strong></p>
<p align="center">--------------------------------------------------------------
</p>
<Table width="75%" border="1" align="center">
{CONTENT}
</table>
</body>
</html> ----------------------------
二、--table_content.tpl--
复制内容到剪贴板
代码:
<tr>
<td>{TD1}</td>
<td>{TD2}</td>
</tr> ----------------------------
要实现的目的是将 table_content.tpl 中的模板内容嵌入到 table.tpl 模板中形成一个完整的表格,具体实现的程序如下:
--start table.php --------------------
复制内容到剪贴板
代码:
<?
require_once "./class/class.smarttemplate.php";
//对表格行列数据符值
$info = new SmartTemplate( "./templates/table_content.tpl" );
$info->assign('TD1','TD1');
$info->assign('TD2','TD2');
//$info->output();
$result=$info->result();
//对表格整体进行赋值
$index = new SmartTemplate( "./templates/table.tpl" );
$index->assign ('TITLE','这是一个表格模板试验程序');
$index->assign('CONTENT',$result);
$index->output();
?> --End table.php--------------------