How to check if headTitle is already used?
To avoid appending or overwriting existing title, which was set earlier in parent views/layout.
Thanks ;)
Update
Exam开发者_开发知识库ple:
$this->headTitle('First title'); // index.phtml
$this->headTitle('Second title'); // some-nested-tpl.phtml
Check whether First title is set and assign Second if not.
You can simply check the content of headTitle and if it's the default then write something else like:
if($this->headTitle() == '<title></title>') {
$this->headTitle('foo')
}
Or write yourself a view-helper to safe yourself some writing time and have a function like
$this->headTitleIfEmpty('foo');
which does the above, so you have a short tag in your templates.
精彩评论