I would have thought though that there can only be one Description so I need
to do
// Layout Call
if ($config->meta->description) {
$this->headMeta()->setName('description', $config->meta->description);
}
// View Call
$this->headMeta()->setName('description', 'Words words words.');
Trouble is the Layout call is getting processed afterwards and overwriting
my view call - can I check if something exists in the array first and then
decide to call the layout setName?
Cheers
2009/10/10 Matthew Weier O'Phinney <[email protected]>
> -- 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/
>