Getting to know Zend_View

Like many other PHP developers I'm keeping an eye on the progress of the Zend Framework. It's currently still in the very early stages of development but is nonetheless worth "getting to know".

These are some notes from a play around with the current View functionality. I generally use a nested layout template file with PHP embedded in HTML. Variables are assigned by a controller file so a layout template may look like this "main_layout.php" file: After some much appreciated help from Paul M Jones and Simon Mundy on the Zend Framework General List, I now have the following three methods of doing the same in the Zend Framework. 

### Use Zend_View::_script()

Include the additional views directly in the layout using the Zend_View::_script() method:

### Use assigned variables

Assign the additional views in the controller file and then use the variables in the layout: In the view controller: $view->header = $view->render('modules/header.php') $view->content = $view->render('page.php') $view->footer = $view->render('modules/footer.php') In the view script:

### Use Zend_View::render()

This seems to be the "proper" solution as it makes full use of the _file stack in render(). Call Zend_View::render() from within the view script: render('modules/header.php') ?> render( $this->content ) ?> render('modules/footer.php') ?> The above three solutions all require a final call to render the whole layout in the view controller file, e.g.: echo $view->render( 'layouts/main_layout.php' );

### Cautionary Note

Since the framework is currently in preview release stage it's possible that the above may change soon after posting this (though I suspect probably not much if at all). ### Update (8th November) As of the latest SVN checkouts Zend_View::render() does not echo the output so you will need to use... render( $this->content ) ?>