views:

60

answers:

3

I need to render a view from inside a view.

For the sake of question, i'll call them blocks.

I have 5 controllers, each of them has an action that is called BlockAction(), and it displays some of the information from that controller.

In the Index page for the whole website I need to call all 5 of those BlockAction views. What could be the best way to do this?

Thanks!

A: 

use partial Views
asked already

MANCHUCK
*(hint)* if you know it was asked already, closevote it
Gordon
Just FYI, you can't close vote until 3000 reputation. However you can comment at 50 reputation, and this "answer" should be a comment.
evolve
Thanks, the link really helped.
Janis Peisenieks
@gordon Yea i cant close vote it yet not enough rep ;)
MANCHUCK
+1  A: 

You might want to take a look into Zend_Layout, I believe you will find it to be a more abstract solution and give you more control over the views. Basically the "layout" is the view which has multiple views within it (Redundant I know).

evolve
A: 

Just adding to the already given answers.

While the approach to have separate controllers and action for blocks is most true to the classic MVC approach, where each part of the UI has it's corresponding controller, it is not advisable to use it with Zend Framework.

In theory you could use the ActionStack Action Helper or Action View helper to call the controller actions. However this would make your application go through the full dispatch cycle for each call.

Further reading:

Gordon
Thanks, for the tip, I'll try to work on this issue.
Janis Peisenieks
just to avoid some potential confusion. The action stack is called when using view helpers. When using partial views, the actionstack is not invoked
MANCHUCK