Zend Framework 使用 html 文件而不是 phtml 作为视图脚本
我们有一个开发人员代码,他是用 php 编写的。当我们研究代码时,我们注意到所有视图的扩展名都是html,而不是phtml。我们通过将文件重命名为 phtml 进行检查,结果出现错误。令人惊奇的是,他们没有在应用程序中做到这一点,而是在 Zend Level 中做到了。
如果我用新下载的内容替换库目录中的 zend 框架,应用程序将停止工作。说找不到视图
有谁知道他们是怎么做到的(修改ZF以搜索html而不是phtml文件)?
还有一件事: 他到处都在使用变量 $this->baseURL
(不是 zF 提供的 $this->baseUrl()
)来保存基本 url。它不是一个助手,我检查了,似乎在代码中的任何地方都找不到声明,但仍然神奇的是它可以通过所有控制器和视图使用。他们是如何实施的?我搜索了所有文件,但没有定义 baseURL
或将选项 baseURL
写入 AUTH
、STORAGE
>,或者任何东西。那么他是如何做到这一点的呢?又修改zf了?
We had a developer code for us, and he did it in php. When we were studying the code, we noticed that all the views have html as their extension instead of phtml. We checked by renaming a file to phtml, and it gives an error. What's amazing is that they have not done this in the app, they have done it at Zend Level.
IF I replace the zend framework in the library directory with a fresh download, the app stops working. saying that the view was not found
Does anyone know how they did this (modified ZF to search for html instead of phtml files)?
One more thing:
all over the place, he's using a variable $this->baseURL
(not $this->baseUrl()
as provided by zF) which holds the base url. Its not a helper, I checked and can't seem to find the declaration anywhere in the code, but still magically it is available through all the controllers and views. How did they implement? I did a search through all the files, but nowhere is baseURL
defined or the option baseURL
written to AUTH
, STORAGE
, or anything. So how did he get to this? Modify the zf again?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
他们可能更改了 Zend Layout 类文件
Zend/Layout.php
。您可以检查
protected $_viewSuffix = 'html';
而不是默认的 phtml。您可以通过将以下内容添加到引导程序来修复此问题,以便升级 Zend Framework 文件。
至于 $baseURL 变量,这可以通过插件或操作助手来设置。
如果您获得视图对象,您可以执行类似
$view->baseURL = 'xxx';
的操作来使其可用。这可以通过插件或操作助手来完成。希望有帮助。
They may have changed the Zend Layout class file
Zend/Layout.php
.You can check for
protected $_viewSuffix = 'html';
instead of phtml which is the default.You can fix this by adding the following to your bootstrap so you can upgrade the Zend Framework files.
As for the $baseURL variable, this could have been set via a plugin, or action helper.
If you get the view object you can do something like
$view->baseURL = 'xxx';
to make it available. This can be done from a plugin or action helper.Hope that helps.
看看
Zend/Controller/Action/Helper/ViewRenderer.php
,您应该在其中找到更改视图后缀的更好方法是将其添加到
application/Bootstrap.php
或者您可以通过所有控制器中的 init 方法来更改它
Zend_Layout
正如 drew010 所提到的,仅更改布局的后缀,而不更改视图的后缀。Have a look at
Zend/Controller/Action/Helper/ViewRenderer.php
where you should findBetter ways to change the view suffix is adding this to the
application/Bootstrap.php
Or you can change it by this init method in all controllers
Zend_Layout
as mentioned by drew010 only changes the suffix of layouts and not of views.