I'm attempting to create a ZF2 view helper which outputs a blog post of varying display formats. The post is made up of a header, body and footer.
I've attempted to create the view helper using the nesting example in the ZF2 docs.
// post helper
public function __invoke( PostInterface $post, $is_single = true ){
$view_model = new ViewModel();
$view_model->setTemplate( 'editorial/partials/complete' );
$view_model->setVariable( 'object', $post );
$view_model->setVariable( 'is_single', $is_single );
$body_model = new ViewModel();
$body_model->setTemplate( 'editorial/partials/xx_display_format_partial_xx' );
$body_model->setVariable( 'object', $post );
$view_model->addChild( $body_model, 'body' );
... repeat for header and footer
return $this->getView()->render( $view_model );
}
// editorial/partials/complete.phtml
echo $this->header;
echo $this->body;
echo $this->footer;
I receive no errors when echoing the view helper. The problem is, there's no output either.
Is what I'm trying to do even possible? If so, what am I doing wrong?