I used below code to render a page in the controller action.
public function userinforeceiveAction()
{
$renderer = new PhpRenderer();
$map = new Resolver\TemplateMapResolver(array(
'userinfo' => __DIR__ . '/userinfo.phtml',
));
$resolver = new Resolver\TemplateMapResolver($map);
$renderer->setResolver($resolver);
$model = new ViewModel();
$model->setTemplate('userinfo');
return new ViewModel();
}
and I echo rendering content in the view.
echo $renderer->render($model);
but it render nothing. Please help me. thanks.
and also its fine work with zf1 by this two lines.
$this->userinfoAction();
$this->$render('userinfo');
Actually what you have done should work with following miner changes
No need of this line within the view
But the best and recommended way is to inject through the module configuration file,
as Adam said
The documentation will provide better explanation