Templates 无法加载模板文件
我将smarty模板与zend framework一起使用,并在其中创建了另一个模块,如admin。在该模块中,Controller正在工作,layout.tpl文件也在工作,但问题是,当我在layout.tpl文件中添加include file语法时,同样的错误也会出现Templates 无法加载模板文件,templates,zend-framework,smarty,Templates,Zend Framework,Smarty,我将smarty模板与zend framework一起使用,并在其中创建了另一个模块,如admin。在该模块中,Controller正在工作,layout.tpl文件也在工作,但问题是,当我在layout.tpl文件中添加include file语法时,同样的错误也会出现 Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file '../index/index.tpl'
Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file '../index/index.tpl'' in
/var/www/docs/sw.com/public/library/Smarty/sysplugins/smarty_internal_template.php:174
Stack trace:
#0 /var/www/docs/sw.com/public/library/Smarty/sysplugins/smarty_internal_template.php(551): Smarty_Internal_Template->isExisting(true)
#1 /var/www/docs/sw.com/public/application/tmp/smarty_compile/898ca70906754084b81f61d3ce7baee3b11bd8d3.file.layout.tpl.php(46): Smarty_Internal_Template->getRenderedTemplate()
#2 /var/www/docs/sw.com/public/library/Smarty/sysplugins/smarty_internal_template.php(436): include('/var/www/docs/s...')
#3 /var/www/docs/sw.com/public/library/Smarty/sysplugins/smarty_internal_template.php(568): Smarty_Internal_Template->renderTemplate()
#4 /var/www/docs/sw.com/public/library/Smarty/Smarty.class.php(328): Smarty_Internal_Template->getRenderedTemplate()
#5 /var/www/docs/sw.com/public/library/Smarty/Smarty.class.php(370): Smarty->fetch('/var/www/docs/s...', NULL, NULL, NULL, true)
#6 /v in /var/www/docs/sw.com/public/library/Smarty/sysplugins/smarty_internal_template.php on line 174
IndexController.php
第三方物流
{$SITE_TITLE}
你好
{include file=“$T_Body”}
index.php
管理
我在windows中也做了同样的事情,但在ubuntu中却不起作用。
我设置了所有权限并检查了所有路径和所有内容。
默认模块在ubuntu中工作,但管理模块不工作对Smarty实现不太确定,但您必须记住,PHPs工作目录是您的项目根路径 您可能希望以这种方式绝对分配它:
IndexController.php
<?php
class Admin_IndexController extends Models_UserCommonController
{
function init()
{
parent::init();
}
public function indexAction()
{
$this->view->assign('T_Body', '../index/index.tpl');
}
}
?>
layout.tpl
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>{$SITE_TITLE}</title>
</head>
<body>
<p>Hello</p>
{include file="$T_Body"}
</body>
</html>
index.php
请记住,这只适用于Zend Framework 2!您的代码表明您使用的不是第二个版本,而是ZF1。否则,您绝对应该继续前进,使用名称空间,并遵循有关如何构建控制器的教程。听起来您指向
index.tpl
文件的路径完全错误。再次检查它是否连接到正确的位置。
$this->view->assign('T_Body', __DIR__ . '/../index/index.tpl');