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 just tested this, and
setName()
should work:Results in:
While:
Results in:
I would recommend setting a view variable for the keywords. For example, in your bootstrap.php you could define a default keywords as follows:
In layout.phtml you would have then:
Finally, in your views (or actions) you could change the meta keywords simply by changing the keywords view variable:
keywords and description generating without controller/action
register 2 plugin in bootstrap
Meta plugin could look like:
navigationArray would be than:
than you can simple call (from layout/view) print $this->pageHeader;
How about:
I found this, which works for me, on Best practice to place meta tags, links and styles in zend framework?
Here's what worked for me. In the layout file you have to make sure that the meta tags are echoed. It's empty at the stage but you will be marking where the meta tags will be outputted. This only disadvantage with this method would be that there doesn't seem to be a way to have a default meta tag so you will have to add the meta tag in each view file.
In the layout file
In the view .phtml file