简体   繁体   中英

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

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

Example:

$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.

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