Smarty 多次调用Smarties display()方法而不是使用includes
哪种方法将我的站点的模板部分放在一起是最佳实践?我更喜欢第一种解决方案,但我不确定使用多个调用来显示()是否是一种好的做法。我正在寻找易于维护和速度Smarty 多次调用Smarties display()方法而不是使用includes,smarty,Smarty,哪种方法将我的站点的模板部分放在一起是最佳实践?我更喜欢第一种解决方案,但我不确定使用多个调用来显示()是否是一种好的做法。我正在寻找易于维护和速度 <?php $smarty->display('header.tpl'); $smarty->display('menu.tpl'); $smarty->display('article1.tpl'); $smarty->display('footer.tpl'); ?> 或者显示单个smarty模板,然后
<?php
$smarty->display('header.tpl');
$smarty->display('menu.tpl');
$smarty->display('article1.tpl');
$smarty->display('footer.tpl');
?>
或者显示单个smarty模板,然后在模板内
{include file="header.tpl"}
<body id={$pageid}>
{include file="menu.tpl"}
{include file="header_inner.tpl"}
Content of page
{include file="footer.tpl"}
{include file=“header.tpl”}
{include file=“menu.tpl”}
{include file=“header_inner.tpl”}
页面内容
{include file=“footer.tpl”}
如果您正在使用Smarty3(您应该这样做),请查看并查看。它允许您像构建类一样定义模板-OOP风格
如果您不能(或不想)使用TI,我建议使用{include}
方法。原因:
Not Modified
处理