首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PHP Smarty模板主页问题

PHP Smarty模板主页问题
EN

Stack Overflow用户
提问于 2015-12-13 06:13:17
回答 1查看 40关注 0票数 2

我想改变我的网站主页,使用php代码,我找到了我需要修改的tpl文件,问题是我没有使用tpl的经验,我想用php写它,但它不起作用。我正在尝试使用:

代码语言:javascript
复制
{include_php file="/path/to/somefile.php"}

使用php语言,但它不工作。如何使用php语言在Smarty模板中使用tpl。

EN

回答 1

Stack Overflow用户

发布于 2015-12-13 06:22:18

我的建议是以下是一个php文件

代码语言:javascript
复制
include_once("/var/www/html/smarty/libs/Smarty.class.php");
$smartyobject=new Smarty();

$varr="stackoverflow"; //php variable it can also be a array";
$smartyobject->assign("website", $varr); //assigning a variable to "website", and this is now a smarty variable.
$smartyobject->display("tplfile"); //this is the actuall file that get displayed, in this tpl file you can use "website" variable {$website} 

smarty有很多in函数循环..所以不需要包含任何php文件。在php文件中做任何您想做的事情,将结果保存在一个变量中,并在tpl文件中显示它。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34245620

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档