Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-06-2008, 08:12 PM
Junior Member
 
Join Date: May 2008
Posts: 4
Default [Zend_Layout] Accessing the same data into several views

Hi everyone,

I'm reading a lot about Zend_Layout, but I can't figure out how to access the same data into more than one view.

For example :

layout.phtml

Code:
<?php
echo $this->layout()->nav;
echo $this->layout()->content;
mycontent.phtml

Code:
<p>hello <?=$this->user['username'];?></p>
mynav.phtml

Code:
<img src="<?=$this->user['avatar'];?>" alt="" />
Assuming my $user array is from a db, it would be nice to read it just once, and not have two actions reading the same data twice.

I could :
- "init" the controller for the user, and then register the data into some property of the controller
- use cache
- use registry
- merge the views when they use the same data

But any of those seem accurate for that problem.

Thank you for your help

elvex
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-06-2008, 11:30 PM
Junior Member
 
Join Date: May 2008
Posts: 4
Default

... or maybe placeholders are meant to do that ?

But what's confusing me is that I don't need to share some html result, but only some objects / data to access at multiple places.
And I still don't know how to create a placeholder shared by multiple actions.

Last edited by elvex : 07-06-2008 at 11:32 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 08:40 PM.