(on Wednesday, 26 November 2008, 03:10 PM -0500):
> 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.
Um... no. render() with a null first argument only renders the current
action as found in the request. There is no way currently to render
*all* actions at once.
> 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!
When you call render() manually, it renders immediately... and then
tells the ViewRenderer not to do any auto rendering. This is to prevent
double-rendering. So, calling render() from init() is a bit self
defeating -- because then your normal view script won't render during
normal execution..
> 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/
>
>
>
--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/
没有评论:
发表评论