用一个变量不就可以了
$mm = $hodat;
$string_Temp = "我是 $mm";
$object_Tpl->assign("test", $string_Temp);$object_Tpl-display("temp.tpl");
$mm = $hodat;
$string_Temp = "我是 $mm";
$object_Tpl->assign("test", $string_Temp);$object_Tpl-display("temp.tpl");
调试欢乐多
不过我是这样的习惯
$object_Tpl->assign('test', $string_Temp);$object_Tpl->display("temp.tpl");
并且我用的后缀名是 HTM
有没有什么不同 ?
一句是必须的,这样才能让人知道你在用什么模板驱动Smarty用htm后缀意义不大,如果你的模板中有他的专有元素,可视性并不好
倒是SmartTemplate模板驱动使用htm后缀较好
我详细点说吧~~headerfrom.inc.tpl:<form method='POST' action='<{$postfrom}>' name='userlog_in'>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="210" id="AutoNumber1">
<tr>
<td width="33%"><IMG src="images/Log_id.gif" width="40" height="17" ><INPUT maxLength=12 size=14 name=username class=inputtext></td>
<td width="33%" rowspan="2">
<input type="image" src="images/btn_login.gif" border=0 width="63" height="41"></td>
<td width="34%" rowspan="2"><A href="<{$reglink}>">
<IMG src="images/btn_join.gif" border=0 width="63" height="41"></A></td>
</tr>
<tr>
<td width="33%"><IMG src="images/Log_pw.gif" width="40" height="17"><INPUT type=password maxLength=12 size=14 name=userpwd class=inputtext></td>
</tr>
<tr>
<td width="33%"> </td>
<td width="34%"> </td>
<td width="33%"> </td>
</tr>
</table>
<{$loginhinput}>
</form>
-------------------------------------------------------
head.inc.tpl:<TABLE cellSpacing=0 cellPadding=0 width="100%" background=images/topbg.gif border=0>
<TR>
<TD width=93><img src="images/spacer.gif" width="93"></TD>
<TD width=821>
<TABLE cellSpacing=0 cellPadding=0 width=821 border=0>
<TR>
<TD width=350 rowSpan=2><img src="images/logo.gif" border="0"></TD>
<TD vAlign=top width=117 height=100 rowSpan=2></TD>
<TD width="354" valign="bottom">
<{$headshow}>
</TD></TR></TABLE></TD>
<TD> </TD></TR></TABLE>
----------------------------------------------------我现在要把headerfrom.inc.tpl放在head.inc.tpl的<{$headshow}>位置,并且要解释headerfrom.inc.tpl里面的标记,我取得headerfrom.inc.tpl的方法是:
-----------------------------------------------------
$stream_Filehead = fopen(__TEMPLASTPATH__."/headerfrom.inc.tpl","r");
$string_headshow = fread($stream_Filehead,filesize(__TEMPLASTPATH__."/headerfrom.inc.tpl"));
fclose($stream_Filehead);$object_Tpl->assign("headshow", $string_headshow);
-----------------------------------------------------
但是这样的话根本就没有解释headerfrom.inc.tpl里面的标记不要建议我把它们做在一起,因为还有别的原因要我必须这样做
也不要我使用include,include_php等的,也不合用哪位老大能有办法啊??