layout content not rendering

View: New views
7 Messages — Rating Filter:   Alert me  

layout content not rendering

by Greg Donald-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In my bootstrap I'm trying to setup a default layout:

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

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


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

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

But it produces nothing.


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?


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

Re: layout content not rendering

by bradley.holt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...

Re: layout content not rendering

by Greg Donald-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 5/28/08, Bradley Holt <bradley.holt@...> wrote:
> 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()."

That was the problem.

Thanks,


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

Re: layout content not rendering

by bradley.holt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Greg,

On Wed, May 28, 2008 at 11:06 AM, Greg Donald <gdonald@...> wrote:
On 5/28/08, Bradley Holt <bradley.holt@...> wrote:
> 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()."

That was the problem.

Interesting, so it appears that the content key is case sensitive (based on your experience). In that case, the documentation should probably be updated to change the uppercase 'CONTENT' to lowercase 'content' and perhaps indicate that the key is case sensitive. Does someone want to file a bug report? :-)
 


Thanks,


--



--
Bradley Holt
bradley.holt@...


Re: layout content not rendering

by weierophinney :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-- Bradley Holt <bradley.holt@...> wrote
(on Wednesday, 28 May 2008, 11:25 AM -0400):

> On Wed, May 28, 2008 at 11:06 AM, Greg Donald <gdonald@...> wrote:
>
>     On 5/28/08, Bradley Holt <bradley.holt@...> wrote:
>     > 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()."
>
>     That was the problem.
>
>
> Interesting, so it appears that the content key is case sensitive (based on
> your experience). In that case, the documentation should probably be updated to
> change the uppercase 'CONTENT' to lowercase 'content' and perhaps indicate that
> the key is case sensitive. Does someone want to file a bug report? :-)

Be my guest, Bradley. :-)

--
Matthew Weier O'Phinney
Software Architect       | matthew@...
Zend - The PHP Company   | http://www.zend.com/

Re: layout content not rendering

by bradley.holt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Matthew,

On Wed, May 28, 2008 at 4:34 PM, Matthew Weier O'Phinney <matthew@...> wrote:
-- Bradley Holt <bradley.holt@...> wrote
(on Wednesday, 28 May 2008, 11:25 AM -0400):
> On Wed, May 28, 2008 at 11:06 AM, Greg Donald <gdonald@...> wrote:
>
>     On 5/28/08, Bradley Holt <bradley.holt@...> wrote:
>     > 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()."
>
>     That was the problem.
>
>
> Interesting, so it appears that the content key is case sensitive (based on
> your experience). In that case, the documentation should probably be updated to
> change the uppercase 'CONTENT' to lowercase 'content' and perhaps indicate that
> the key is case sensitive. Does someone want to file a bug report? :-)

Be my guest, Bradley. :-)

From what Greg says it sounds like it is an issue - but I'd rather take the time to confirm that I can reproduce the issue myself before filing a bug report ;-)

If someone else gets to this before I do, please let me know. Thanks!
 


--
Matthew Weier O'Phinney
Software Architect       | matthew@...
Zend - The PHP Company   | http://www.zend.com/



--
Bradley Holt
bradley.holt@...


Re: layout content not rendering

by bfoust :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Greg Donald-3 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' ) );

I'm not exactly sure what to do with that new $layout variable however.
If you just leave the contentKey unspecified, it defaults to "content", so you might find it less confusing to just leave everything set to the defaults by:

1. Using only:

    Zend_Layout::startMvc();

2. Now your default layout for each module is:

      <modulename>/views/scripts/layout.phtml

3. and the default view that gets rendered into $this->layout()->content  is still:

      <modulename>/views/scripts/index/index.phtml