Another way around this would be to set your default description early (like
in a bootstrap init method) and let your view scripts override it
when necessary.
--
Hector


On Mon, Oct 12, 2009 at 7:07 PM, Ian Warner
<[email protected]>wrote:

> Further to this I have been examining the Code to try and get at a property
> to see if it already exists:
>
> I see this in: abstract class
> Zend_View_Helper_Placeholder_Container_Standalone
>
>     /**
>      * Overloading: retrieve property
>      *
>      * @param  string $key
>      * @return mixed
>      */
>     public function __get($key)
>     {
>         $container = $this->getContainer();
>
>         if (isset($container[$key])) {
>             return $container[$key];
>         }
>
>         return null;
>     }
>
> However as the Container is a sequential object it would be lucky to get
> the property I want based on the key wouldn't it as I need to pass in an int
> value
>
> Zend_View_Helper_Placeholder_Container Object ( [0] => stdClass Object (
> [type] => name [name] => title [content] => Content. [modifiers] => Array (
> ) ) [2] => stdClass Object ( [type] => name [name] => keywords [content] =>
> keywords [modifiers] => Array ( ) ) [3] => stdClass Object ( [type] => name
> [name] => description [content] => description [modifiers] => Array ( ) ) )
>
> What i want is the property based on the name.
>
> Sorry if I am missing a trick here but just need to see if Description is
> already set if it is then do not set again.
>
>
> 2009/10/13 Ian Warner <[email protected]>
>
> 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/
>>>
>>
>>
>

Reply via email to