Php 查看zend framework中另一个模块中模块的输出
我有两个模块 1-登录模块 2-应用模块 我想查看MyLoginModule/view/MyLoginModule/index/index.phtml(在这个文件中我有登录表单) 在我的主页上 我使用应用程序模块创建主页 我想在此文件中查看MyLoginModule中的登录表单:module\Application\view\Application\index\index.phtml 或 我有联系我们模块我想查看模块\contact us\view\contact us\index\index.phtml 在我的主页上 使用应用程序模块创建我的主页Php 查看zend framework中另一个模块中模块的输出,php,zend-framework,module,Php,Zend Framework,Module,我有两个模块 1-登录模块 2-应用模块 我想查看MyLoginModule/view/MyLoginModule/index/index.phtml(在这个文件中我有登录表单) 在我的主页上 我使用应用程序模块创建主页 我想在此文件中查看MyLoginModule中的登录表单:module\Application\view\Application\index\index.phtml 或 我有联系我们模块我想查看模块\contact us\view\contact us\index\index.
<?php
echo $this->loginForm();
?>
thanx提前我解决了它
代码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();
?>
是正确的