-- Ian Warner <[email protected]> wrote
(on Saturday, 10 October 2009, 02:38 AM +0900):
> I have this in my Layout script - setting some default Meta Data:
> 
> // Setting META Headers come from the Config File
> if ($config->meta->keywords) {
>     $this->headMeta()->appendName('keywords', $config->meta->keywords);
> }
> 
> if ($config->meta->description) {
>     $this->headMeta()->appendName('description', $config->meta->description);
> }
> 
> echo $this->headMeta() . PHP_EOL;
> 
> 
> Now in a View I want to overide so I call:
> $this->headMeta()->setName('description', 'Words words words.');
> 
> I would expect there to be only one description on the site - but two are
> printed the default and the one from the view.
> Is this a bug or expected behaviour - if so how do I make sure only one is
> visible.

Expected behavior; setName() sets the first element in the array.

You can *clear* what's in the array by passing an empty array to
exchangeArray(), as the containers extend ArrayObject:

    $this->headMeta()->exchangeArray(array());
    $this->headMeta()->setName('description', 'Words words words.');

-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/

Reply via email to