zend framework 2 change head title

2k Views Asked by At

I'm trying to change headtitle on ZF2 but it always say "ZF2 Skeleton Application" when i paste it on FB How can I change it? I tried few things and cant make it work

I event tried raw HTML inside head tag to put it and it doesn't work, BUT on my other pages this works but don't know why

echo $this->headTitle('you are on '.$news.' ');

inside PHP ofc

2

There are 2 best solutions below

0
On

If you want to set head title, Do not use 'echo' in front, just use:

$this->headTitle('you are on ...');

...in your view php file.

If you want to change the head title from inside a controller method use:

$this->getServiceLocator()->get('ViewHelperManager')->get('HeadTitle')->set('my title')
0
On

To my understanding you want to change the head title of the main (front page). You can put the following in your layout.phtml page.

<?php echo $this->headTitle('you are on'. $this->translate($news))->setSeparator(' - ')->setAutoEscape(false); ?>