php - How does Zend Framework 2 render partials inside a module? -
i've got directory structure inside module:
api ├── module.php ├── config │ └── module.config.php ├── src │ └── ( ..etc ..) └── view ├── api │ └── api │ └── index.phtml └── partial └── test.phtml then, i'm doing this:
<?= $this->partial('partial/test.pthml', array()); ?> however, get:
05-jun-2012 14:56:58] php fatal error: uncaught exception 'zend\view\exception\runtimeexception' message 'zend\view\renderer\phprenderer::render: unable render template "partial/test.pthml"; resolver not resolve file' in /users/jeff/web/n/vendor/zendframework/zendframework/library/zend/view/renderer/phprenderer.php:463
where should partials go?
this can achieved
echo $this->partial('layout/header', array('vr' => 'zf2')); you can access variable in view using
echo $this->vr; don't forget add following line in view_manager of module.config.php file.
'layout/header' => __dir__ . '/../view/layout/header.phtml', after adding looks this
return array( 'view_manager' => array( 'template_path_stack' => array( 'user' => __dir__ . '/../view' , ), 'display_not_found_reason' => true, 'display_exceptions' => true, 'doctype' => 'html5', 'not_found_template' => 'error/404', 'exception_template' => 'error/index', 'template_map' => array( 'layout/layout' => __dir__ . '/../view/layout/layout.phtml', 'layout/header' => __dir__ . '/../view/layout/header.phtml', 'error/404' => __dir__ . '/../view/error/404.phtml', 'error/index' => __dir__ . '/../view/error/index.phtml', ), ), );
Comments
Post a Comment