修改 Zend_ViewHelper_Pagination_Controller 部分路径
我有一个 Zend-Framework 应用程序。我正在使用 Zend_Controller_Front
提供的模块结构。这是我的目录结构的一小段摘录(仅是这个问题的重要部分):
root-directory
- modules
- blog
- views
- scripts
- index_index.phtml
- views
- pagination_control.phtml
如您所见,我有特定于模块/控制器/操作的视图脚本。这些视图位于相应的路径中(在本例中为modules/blog/views
)。我还有一个更通用的视图目录,位于我的应用程序的根目录中。
我是什么现在要做的是调用modules/blog/views/scripts/index_index.phtml
中的PaginationControl
-ViewHelper,但是这个View-Helper会呈现一个部分视图,就像你一样。 ViewHelper 尝试在同一目录中定位部分视图(即 modules/blog/views/scripts )。因为我想使用相同的视图部分脚本(pagination_control.txt)。 我想使这个视图部分可以从每个模块访问,所以我想将该文件放在根目录中的通用 views
文件夹中。
phtml)在不同的模块中, 不ViewHelper 总是在相应的模块文件夹中查找视图脚本。
任何人都可以帮助我从我的常规 views
目录中访问它吗?
I've got a Zend-Framework application. I'm using the module-structure which Zend_Controller_Front
provides. Here is a small excerpt from my directory-structure (only the important parts for this question):
root-directory
- modules
- blog
- views
- scripts
- index_index.phtml
- views
- pagination_control.phtml
As you can see I've got view-scripts that are specific to a module/controller/action. These views are located in the corresponding path (in this case like modules/blog/views
. I've also got a more general view-directory located in the root-direcetory of my application.
What I am doing now is to call the PaginationControl
-ViewHelper in modules/blog/views/scripts/index_index.phtml
. This View-Helper however renders a partial-view, as you know. The ViewHelper tries to locate the partial-view within the same directory (meaning modules/blog/views/scripts
. Since I want to use the same view-partial-script (pagination_control.phtml
) in different modules I want to make this view-partial accessable from each module. So I want to put that file in the general views
-folder in the root-directory.
However this doesn't work. The ViewHelper always looks for the view-script in the corresponding module-folder.
Anyone can help to make it accessable from my general views
-directory?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如您在此处所看到的,由于 ZF 1.6.2 分页控件可以采用 < strong>array 而不是部分参数的字符串,在这个数组中,您首先设置部分的名称,第二部分设置模块名称。这仍然是未记录。
使用数组,您可以指定一个模块(“通用”?)供部分使用。
真正的调用将是(使用 $partial 你的 paginationControl() 视图助手的第三个参数):
如果你有一个“通用”模块,这很有用。
现在您正在使用共享文件夹。您应该以这种方式(在 Boostrap 或资源代码中)将其安装为 Zend_View 的共享文件夹:
或者更好:
然后您不应该被要求指定任何模块目录。 Zend_View 应始终检查此文件夹中的部分内容。
As you can see here, since ZF 1.6.2 pagination control can take an array instead of a string for the partial argument, and in this array you set 1st the name of the partial and in 2nd the module name. This is still undocumented.
Using an array you can specify a module ('common'?) for the partial to use.
The real call will be (with $partial your 3rd argument to the paginationControl() view helper ):
This is usefull if you have a 'common' module.
Now here you are using a shared folder. You shoudl have installed it as a shared folder for your Zend_View this way (in a Boostrap or ressource code):
or better:
And then you should'nt be required to specify any module directory. Zend_View should always check for a partial in this folder.