无法在布局视图中回显 headTitle
我的 headTitle 已运行,但我无法在布局文件中回显它,因为我需要它作为页面标题。
我就是这样做的:
Bootstrap.php:
protected function _initDefaultHelpers() {
$this->bootstrap('view');
$view = $this->getResource('view');
$view->headTitle('Awesome Website');
$view->headTitle()->setSeparator(' - ');
我的控制器:
public function indexAction() {
$this->_helper->layout()->getView()->headTitle('IndexPage');
}
当我打开索引时,我得到:Awesome Website - IndexPage,这是完美的。
但在我的 master.phtml 中,我使用:
<?php echo $this->headTitle(); ?>
绝对没有给出任何内容。此时我只想要标题“IndexPage”而不是整个标题,所以这也必须考虑。
提前致谢。
I got my headTitle up running, except i cannot echo it in my layout file as i need it for page header.
This is how i done it:
Bootstrap.php:
protected function _initDefaultHelpers() {
$this->bootstrap('view');
$view = $this->getResource('view');
$view->headTitle('Awesome Website');
$view->headTitle()->setSeparator(' - ');
My Controller:
public function indexAction() {
$this->_helper->layout()->getView()->headTitle('IndexPage');
}
When i open index i get: Awesome Website - IndexPage, which is perfect.
But in my master.phtml where i use:
<?php echo $this->headTitle(); ?>
Gives absolutely nothing. At this point i only want the title "IndexPage" and not the entire title, so this also has to be considered.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这项工作:使用 zend 工具创建新项目后在本地进行了测试!
//application.ini
//into Bootstrap.php
//into layout.phtml
//into view
//create view/helper /PageTitle.php
之后您的页面名称将为:Foo :: Bar
this work: tested by me locally after creating a new project with zend tool!
//application.ini
//into Bootstrap.php
//into layout.phtml
//into view
//create view/helper/PageTitle.php
After that the name of your page will be: Foo :: Bar