我有一个小问题,但不知道如何解决这个问题。
这是我的索引。
<body>
{include file='header.tpl'}
{include file='leftmenu.tpl'}
<div id=content>
{include file="news.tpl" }
{include file="rightmenu.tpl"}
</body>
我的问题是这一行
<div id=content>
{include file="news.tpl" }
news.php
是一个应该显示news.tpl
的文件,因为它是我的新闻系统。
在news.php
中,我查询mysql数据库,并把结果给news.tpl
。
但是当我写上面的行,news.tpl
不知道结果来自哪里。
希望有人能帮忙。
你这样做,Smarty_Data
将帮助你
$data = new Smarty_Data;
$data->assign('foo','bar');
$smarty->display('news.tpl',$data);
将news
数组发送给assign
函数
这将是一个很好的选择。您可以简单地添加PHP标记来包含PHP文件
{php}包括"news.php";{/php}