2008年11月26日星期三

Re: [fw-mvc] Named response segments in view scripts

Sounds plausible, if not a little ugly...but I can't get it to work for some odd reason...

I have an "EventsController" with an action "list"...at the end of the action, I have an actionstack with different actions from the "SideboxController"...

SideBox controller has an init() function  which looks like this:
public function init() {
        $this->render(null, 'sideboxes');         
}

Which I was hoping would output all actions from this controller into the sideboxes segment.

It seemed to work in my layout script, but in the view script (events/list.phtml) I have <?=Zend_Controller_Front::getInstance()->getResponse()->getBody('sideboxes');?>

...which doesn't display anything!


On Wed, Nov 26, 2008 at 10:57 AM, Matthew Weier O'Phinney <matthew@zend.com> wrote:
-- Avi Block <atblock@gmail.com> wrote
(on Wednesday, 26 November 2008, 07:40 AM -0800):
>
> How do I access a named response segment in a view script which is not my
> layout script?
> I have a couple of pages within my layout that have a sidebar themselves,
> and i'm trying to render to that sidebar using an actionstack.

Grab it from the response object:

   $response = Zend_Controller_Front::getInstance()->getResponse();
   $content  = $response->getBody($segmentName);

> Alternatively, I would like to do this via a "sublayout"...but I can't
> figure out how to render a layout within another layout.

--
Matthew Weier O'Phinney
Software Architect       | matthew@zend.com
Zend Framework           | http://framework.zend.com/


没有评论: