ZF2: How to render view from other module

2019-09-16 02:54发布

问题:

I have a problem with rendering view from other module.

For example: I'm on page news.phtml and I need to add 'Add comment' page. The view of adding comments is in other module 'Comments' in file add.phtml.

I have no idea how to include this file on news page. I've tried something like this:

echo $this->render('module/Comments/view/comments/index/add.phtml'); 
echo $this->render('../../Comments/view/comments/index/add.phtml');

but nothing works. How could I do that?

回答1:

you need to use partial view helper

echo $this->partial('comments/index/add');