« Return to Thread: layout content not rendering

Re: layout content not rendering

by bradley.holt :: Rate this Message:

Reply to Author | View in Thread

Greg,

On Wed, May 28, 2008 at 12:21 AM, Greg Donald <gdonald@...> wrote:
In my bootstrap I'm trying to setup a default layout:

$layout = Zend_Layout::startMvc( array( 'layout'     => 'application',
                                       'layoutPath' =>
"$dirname/../views/layouts",
                                       'contentKey' => 'CONTENT' ) );

This all looks correct except for one thing. I know the example in the documentation uses all uppercase 'CONTENT' but it also says:

"contentKey: the layout variable used for default content (when used with the MVC). Default value is 'content'. Accessors are setContentKey() and getContentKey()."

I'm not sure if the content key is case sensitive but you might want to try changing uppercase 'CONTENT' to lowercase 'content' or removing that option all-together and letting it default to 'content'. I always try to assume case sensitivity, just to be safe :-)

Can anyone say for sure if the content key is case sensitive or not? I'm assuming it's not case sensitive based on the documentation.
 


I'm not exactly sure what to do with that new $layout variable however.

I use the $layout variable to get its view and set that up, for example:

$view = $layout->getView();
$view->headTitle('Some Title');

But, I don't think there's any requirement that you get a reference to the layout if you're not going to use it.
 



So then in my layout file, application.phtml, I have this:

<?php echo $this->layout()->content; ?>

This looks correct as well.
 


But it produces nothing.

Do you get no output at all or do you get the layout without the content? In other words, is your layout not rendering at all our is your layout rendering but you're getting no content in the layout?
 



My controller looks like this:

<?php

class IndexController extends Zend_Controller_Action
{
 public function indexAction()
 {
   $this->render();
 }
}


My view file, index.phtml, looks like this:

<p>In index view</p>


So what do I have to do to get the content from my view template to
render in my layout?

A couple other troubleshooting questions. Are you getting any errors (and do you have error reporting turned on)? Are you sure your rewrite is working correctly?
 



--
Greg Donald
http://destiney.com/



--
Bradley Holt
bradley.holt@...

 « Return to Thread: layout content not rendering