Resetting a Placeholder?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Resetting a Placeholder?

Tim Stiles-2
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.

Tim Stiles,
Co-Organizer of DallasPHP
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Resetting a Placeholder?

weierophinney
Administrator
-- Tim Stiles <[hidden email]> 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            | [hidden email]
Zend Framework          | http://framework.zend.com/