查看zend框架中另一个模块中模块的输出


view output of module in another module in zend framework

我有两个模块1-登录模块2-应用程序模块我想查看MyLoginModule/view/MyLoginModule/index/index.phtml(在这个文件中我有登录表单)在我的主页上我使用应用程序模块创建主页我想在MyLoginModule中的以下文件中查看我的登录表单:module''Application''view''Application''index''index.phtml

我有联系我们模块我想查看模块''联系我们''查看''联系我们''index''index.phtml在我的主页

我的主页创建与应用程序模块

乙醇提前

我解决

代码ViewHelper

namespace Login'View'Helper;
use Zend'View'Helper'AbstractHelper;
use Zend'ServiceManager'ServiceLocatorAwareInterface;
use Zend'ServiceManager'ServiceLocatorInterface;
use Zend'View'Model'ViewModel;
use Login'Form'LoginForm as Formulaire;
class LoginForm extends AbstractHelper implements ServiceLocatorAwareInterface
{
    protected $sm;
    public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
    {
        $this->sm = $serviceLocator;
        return $this;
    }
    public function getServiceLocator()
    {
        return $this->sm;
    }
    public function __invoke()
    {
        $form = new Formulaire();
        $layout = new ViewModel(array(
            'form' => $form
        ));
        $viewRender = $this->getServiceLocator()->getServiceLocator()->get('ViewRenderer');
        $layout->setTemplate('login/index/index.phtml');
        return $viewRender->render($layout);
    }
}

登录模块中module.config.php中的语句

'view_helpers' => array(
        'invokables' => array(
            'loginForm' => 'Login'View'Helper'LoginForm'
        )
    ),

根据应用模块使用

<?php
   echo $this->loginForm();
?>

是否正确