Skip to content
Harmen Janssen edited this page Jun 28, 2016 · 2 revisions

Views

Rendering Twig templates

Next to Zend Framework's own phtml templates, Garp also supports Twig rendering.

Read more about Twig rendering in its own section

Practical answers to common questions:

This is mostly straight up Zend Framework stuff, but it's a helpful FAQ of things you may encounter in the Garp context.

Disable layout:

$this->_helper->layout->disableLayout();

Render custom script:

// Render immediately with current parameters:
$this->renderScript('post/view.phtml');

// Simply alter the view that will be rendered after the controller action finishes:
$this->_helper->viewRenderer('post/view', null, true)

Use particular layout:

$this->_helper->layout->setLayout('xml');

Is layout enabled?

$this->_helper->layout->isEnabled();

Use a Garp layout:

$this->_helper->layout->setLayoutPath(GARP_APPLICATION_PATH.'/modules/g/views/layouts');
$this->_helper->layout->setLayout('dinges');

Do not render a view:

$this->_helper->viewRenderer->setNoRender(true);

To get to the view in a controller plugin:

$viewObj = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');

Custom view helpers

Garp defines a bunch of custom view helpers:

Clone this wiki locally