【发布时间】:2011-08-24 06:07:04
【问题描述】:
好的开始我使用的是最新的 Smarty 版本,一切都设置好了。
我的问题是我有一个名为 layout.tpl 的整个网站的主模板,然后是 home.tpl、about.tpl 等每个页面的子模板...
index.php(家用)
require('Smarty.class.php');
// --
$smarty = new Smarty;
$smarty->template_dir = 'C:/xampp/htdocs/EMP3/view/templates';
$smarty->config_dir = 'C:/xampp/htdocs/EMP3/view/config';
$smarty->cache_dir = 'C:/xampp/smarty/cache';
$smarty->compile_dir = 'C:/xampp/smarty/templates_c';
$smarty->display('home.tpl');
主页.tpl
{extends file="layout.tpl"}
{block name=title}Home{/block}
{block name=body}
<div>Sample</div>
{/block}
布局.tpl
// Long html file which makes use of the blocks from home, about ect...
我的问题是 layout.tpl 中的 html 内容是隐藏还是显示取决于用户是管理员还是普通用户。如何将这些 PHP 值传递给 layout.tpl?通过 home.tpl?有没有更好的方法来实现这一点?
谢谢
【问题讨论】:
标签: php smarty templating