문제

I've got a Zend-Framework application. I'm using the module-structure which Zend_Controller_Frontprovides. 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?

도움이 되었습니까?

해결책

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->view->partial($partial[0], $partial[1], $pages);

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):

$view->addScriptPath("/root-directory/views");

or better:

$view->addScriptPath("/root-directory/views/partials");

And then you should'nt be required to specify any module directory. Zend_View should always check for a partial in this folder.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top