2009年10月1日星期四

Re: [fw-mvc] Resetting a Placeholder?

-- Tim Stiles <monkeyt@mac.com> wrote
(on Thursday, 01 October 2009, 10:20 PM -0500):
> I have a widget on each page rendered into a View's placeholder by a
> pre-dispatch plugin. There are a very few pages where I don't want to see it.
>
> Is there a way to actively wipe out that placeholder in the controller rather
> than test for those pages all the time? Placeholder method set() doesn't seem
> to do it, though append() and prepend() work as I expect.
>
> Creating the widget does work that would otherwise happen elsewhere, so I don't
> really care if it builds or not. But with only two or three URLs where it's
> not wanted, I don't want to overhead of a test on the other 99% of pages.

The placeholder container actually extends ArrayObject, so you can call
exchangeArray() on it to empty it out:

$this->placeholder()->exchangeArray(array());

(You can substitute in headTitle, headScript, etc. for "placeholder" in
the above.)

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

没有评论: