Take the 2-minute tour ×

Currently I'm finding I have to keep duplicating partials for different modules.

I would like to have a case directory for all partials to be accessed.

Does anyone have a good way of doing this?


share|improve this question
add comment

2 Answers

up vote 8 down vote accepted
$this->partial('directoryOfPartials/partial.phtml', $model);

I think you can also use $this->partial with three arguments. The second argument is a module name and the third argument becomes the model.

Taken From: http://framework.zend.com/manual/en/zend.view.helpers.html

Example #10 Rendering Partials in Other Modules Sometime a partial will exist in a different module. If you know the name of the module, you can pass it as the second argument to either partial() or partialLoop(), moving the $model argument to third position. For instance, if there's a pager partial you wish to use that's in the 'list' module, you could grab it as follows:

<?php echo $this->partial('pager.phtml', 'list', $pagerData) ?>

In this way, you can re-use partials created specifically for other modules. That said, it's likely a better practice to put re-usable partials in shared view script paths.

EDIT - Accessing view partials from within a Controller's Action scope

share|improve this answer
Thanks, this is great for the view, however I have a query about using it via the controller, will reply in a new post below to be clearer –  azz0r Mar 31 '10 at 10:41
what to do in view when you set partial in helper? I mean after that, what you posted after your edit? You set partial to comments.phtml, but what to do with that in view? TIA –  prostynick Nov 9 '10 at 16:44
add comment

Excellent thanks :)

However, how do I do this via the controller? I have fancybox and have set up the ajax layout:


$errors = array('You have lost your rights to download this clip, you have downloaded it the maximum amount of times.');

$this->render($this->view->partial('partials/errors.phtml', 'default', array('errors' => $errors)), NULL, true);

The pop up window as required but with the following error:

Problem: Method "partial" does not exist and was not trapped in __call()

I kinda of assumed the $this->view->partial would be the same as using $this->partial inside the view template, but I guess not. Ideas?


Bootstrap initView, added:


Moved my partials to that directory. Then in my controller I do:

$this->view->form  = $form;

Thanks goes out to #zftalks SmartSsa

share|improve this answer
$this->view->getHelper('partial')->partial('comments.phtml'); I also added it to my answer. –  Ballsacian1 Mar 31 '10 at 17:59
add comment

Your Answer


