how to render template into variable in ZF2

Categories: php

Следующий пример показывает как можно просто отрендерить шаблон в переменную в Zend Framework 2

<?php 
 
public function coolAction()
{
	$d = array();
	$r = new PhpRenderer();
	$resolver = new \Zend\View\Resolver\TemplateMapResolver();
 
	$resolver->setMap(array(
		'confirmation_template' => __DIR__ . '/../../../view/user/mail/confirmation.phtml' // full path to template
	));
	$r->setResolver($resolver);
	$model = new ViewModel($d);
	$model->setTemplate('confirmation_template');
	$x = $r->render($model);
}
?>

No comments here yet Write here gently

No webmentions were found.

Comments powered by Talkyard.