Zend 中的简单文件包含问题?
我在 ubuntu 上创建了一个 zend 项目,位于 /var/www/student/ 目录中。
现在我在这个位置有 head.phtml 文件:
/student/application/views/scripts/index/head.phtml
当我尝试
/student/application/modules/test/views/scripts/all/index.phtml
像这样包含 head.phtml 文件时:
echo $this->partial('index/head.phtml');
它给了我以下错误:
Message: script 'index/head.phtml' not found in path (/var/www/student/application/modules/notification/views/scripts/)
包含文件始终是一个困难为我工作。如何解决这个问题。我必须在许多模块中包含这个文件,那么什么是永久解决方案,我不应该猜测路径
谢谢
I have created a zend project on ubuntu which is in /var/www/student/ directory.
Now I have head.phtml file in this location:
/student/application/views/scripts/index/head.phtml
When I try to include head.phtml file in
/student/application/modules/test/views/scripts/all/index.phtml
Like this:
echo $this->partial('index/head.phtml');
It gives me following error:
Message: script 'index/head.phtml' not found in path (/var/www/student/application/modules/notification/views/scripts/)
Including files is always a difficult job for me. How to fix this. I have to include this file in many modules then what is permanent solution for this that I should not guess the path
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以添加多个路径来查找脚本视图文件。最好的方法是在所有常见文件的引导文件中执行此操作(如标题、页脚、元数据...)。
只需在引导程序中添加一个 setupView 方法,您可以在其中处理与视图相关的所有内容:
You can add several path to look for script view files. The best way is to do it in the bootstrap file for all your common files (like head, footer, metas...).
Just add a setupView method in your bootstrap where you deal with everything which is realted to your views :
我在控制器的
init()
函数中添加了以下行。在视图中添加 head.phtml 文件,如下所示:
文件已成功添加。
I added following line in Controller's
init()
function.Add head.phtml file in view like this:
File is successfully added.