So I have some default meta tags on layout.phtml set using
$this->headTitle() and $this->headMeta()->appendName()
and is echoed at layout.phtml's header
My question is: How do I change those default meta tags from the view file such that they are replaced?
I tried using:
$this->headMeta()->appendName() or setName()
Instead of replacing the old default meta tags, it would create an entirely new meta tag. How can I replace them?
I would recommend setting a view variable for the keywords. For example, in your bootstrap.php you could define a default keywords as follows:
protected function _initSetDefaultKeywords() {
$view = $this->bootstrap('view')->getResource('view');
$view->keywords = 'default keywords';
}
In layout.phtml you would have then:
<?php echo $this->headMeta()->appendName('keywords', $this->keywords); ?>
Finally, in your views (or actions) you could change the meta keywords simply by changing the keywords view variable:
// in an action
$this->view->keywords = 'new kewords';
//or in a view
<?php $this->keywords = 'new kewords'; ?>