简体   繁体   中英

Setting Page Title - headTitle() - Zend Framework 2 ZF2

I am currently in the process of building an application with ZF2, everything is going well so far, but I am just having trouble with the page titles (as in the <title> tag in the <head> ).

In my layout.phtml I have it statically set a string using $this->headTitle() .

I want it to basically include the name of the module, controller and action by default, just like the doc page suggests:
http://framework.zend.com/manual/2.1/en/modules/zend.view.helpers.head-title.html

However when I try and implement the example code, I get an Exception. Frankly the documentation should at least show you the best place to put this code.

I am looking for an example that a ZF2 noob can follow. I basically want to place some code somewhere (presumably Application\\Module.php) so that I can set the default title as "Module - Controller - Action", then I need an example of how to override it easily from each controller or view (whichever is preferred)... please help! :)

As per Sams comment... Readthedocs has the working example: http://zf2.readthedocs.org/en/latest/modules/zend.view.helpers.html#headtitle-helper

Thanks for your help Sam!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM