Zend 框架:headTitle()->append() 问题 [英] Zend Framework: headTitle()->append() issue
问题描述
有没有人遇到过这个问题...
Has anyone run into this problem...
在我的 layout.phtml 中有:
In my layout.phtml I have:
<head>
<?= $this->headTitle('Control Application - ') ?>
</head>
然后在 index.phtml 我有:
then in index.phtml I have:
<? $this->headTitle()->append('Client List'); ?>
我希望,当我转到我的索引操作时,标题应该是控制应用程序 - 客户端列表",但我有客户端列表控制应用程序 - "
I expect that, when I go to my index action, the title should be 'Control Application - Client List' but instead I have 'Client ListControl Application - '
这是怎么回事?我该如何解决这个问题?
What is going on? How can I fix this?
推荐答案
headTitle() 的默认行为是追加到堆栈.在 layout.phtml 中调用 headTitle() 之前,您的堆栈是:
Default behaviour of the headTitle() is to append to the stack. Before calling headTitle() in layout.phtml, your stack is:
客户名单
然后,您使用第一个参数而不是第二个参数调用 headTitle (这使其默认为 APPEND),从而产生以下堆栈:
Then, you call headTitle with the first argument and no second argument (which makes it default to APPEND), resulting in the following stack:
ClientListControl 应用程序 -
ClientListControl Application -
解决方案,在 layout.phtml 中:
<?php
$this->headTitle()->prepend('Control Application -');
echo $this->headTitle();
?>
这篇关于Zend 框架:headTitle()->append() 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!