-- Nick Lo <[EMAIL PROTECTED]> wrote
(on Wednesday, 08 November 2006, 07:23 PM +1100):
> I did get a reply that pointed out that the updated Zend_View::render 
> () now does not echo.
> 
> The answer is to go from this...
> 
> <?php $this-> render('modules/header.php') ?>
> 
> ...to this...
> 
> <?php echo $this-> render('modules/header.php') ?>
> 
> ...simple really!

Actually, it's been in the code like that for some time -- render never
actually echo'd, only returned a value. The issue was that there was a
bug in how render() returned results such that calling render() within
another template led to an output buffering condition whereby the
contents were echo'd instead of returned. In other words, you were
relying on a bug for the output ;-)

As already pointed out to you, explicitly echoing works, as does using
the shorthand php tags:

    <?= $this->render('modules/header.php') ?>

> > Hello,
> >
> > I've been developing off regularly updated svn checkouts and one of  
> > the latest updates to Zend_View (in 1487 I think) seems to be  
> > breaking render() particularly with regard to calling render()  
> > within templates like so...
> >
> > <body>
> >    <?php $this-> render('modules/header.php') ?>
> >    <?php $this-> render( $this-> content ) ?>
> >    <?php $this-> render('modules/footer.php') ?>
> > </body>
> >
> > ...as outlined in...
> >
> > "Use Zend_View::render()"
> >
> > http://www.ingredients.com.au/nick/2006/06/10/getting-to-know- 
> > zend_view/
> >
> > After attempting to find the cause of the issue in  
> > Zend_View_Abstract I reverted to using the latest 0.2 release and  
> > all works fine.
> >
> > What I did note was that Zend_View::run() did not seem to echo the  
> > files set within a template so...
> >
> >    protected function _run()
> >    {
> >        echo 'include ' . func_get_arg(0);
> >        include func_get_arg(0);
> >    }
> >
> > ...would only echo the parent "layout" template e.g from my article  
> > that would be this call to render...
> >
> > echo $view-> render( 'layouts/main_layout.php' );
> >
> > Hope that's somewhat clear... I'm happy to give more details if  
> > needed but I may be already be missing something obvious.

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to