Search code examples
zend-frameworkmeta-tags

Zend Framework change meta tags


I have some default meta tags on layout.phtml:

$this->headMeta()
    ->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8')
    ->appendName('description', 'test test test')
    ->appendName('keywords', 'test test test')
    ->appendName('robots', 'index, follow')
    ->appendName('language', 'bg')
    ->appendName('googlebot', 'index, follow, archive')
    ->appendName('tags', 'test test test');

How can I add more keywords and description to existing from view, I try this (/views/scripts/index/news.phtml:

echo $this->headMeta()
    ->appendName('description', 'new desc')
    ->appendName('keywords', 'new keys');

but don't work. Zend create two description and two keywords tags.


I want to add new keywords and descriptions to yet existing. Exp. if in layout.phtml I generate that:

$this->headMeta()
->appendName('keywords', 'music, song, mp3')

in /views/scripts/index/news.phtml I want to add new keywords, to be added to already existing in layout.phtml.


Solution

  • Don't echo the headMeta() helper in the view script - this is what's creating the duplicate. Just call it instead:

    <?php
    $this->headMeta()
         ->appendName('description', 'new desc')
         ->appendName('keywords', 'new keys');
    ?>