开发者

How can I check if headTitle is already used in Zend Framework?

开发者 https://www.devze.com 2023-04-10 08:09 出处:网络
How to check if headTitle is already used? To avoid appending or overwriting existing title, which was set earlier in parent views/layout.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消