在布局视图中不能回显headTitle


Cannot echo headTitle in layout view

我得到了我的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网站- IndexPage,这是完美的。

但在我的主人。这里我使用:

<?php echo $this->headTitle(); ?>

绝对没有给出。在这一点上,我只想要标题"IndexPage",而不是整个标题,所以这也必须考虑。

此作品:在使用zend工具创建新项目后由我在本地进行测试!

//application.ini

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Foo"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
; layout stuff
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
; view stuff
resources.view[] = ""
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

//到Bootstrap.php

protected function _initDefaultHelpers() {
    $this->bootstrap('view');
    $view = $this->getResource('view');
    $view->headTitle('Foo');
    $view->headTitle()->setSeparator(' :: ');
    $view->doctype("XHTML1_STRICT");
}

//到layout.phtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="it" xml:lang="it">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <?=$this->headTitle()?>
</head>
<body>
    <?=$this->pageTitle?>
    <?=$this->layout()->content?>
</body>
</html>

//到视图
<? $this->pageTitle("Bar"); ?>

//创建视图/帮助/PageTitle.php

<?
class Zend_View_Helper_PageTitle extends Zend_View_Helper_Abstract
{
    public function pageTitle($title)
    {
        $this->view->headTitle($title);
        $this->view->pageTitle = '<h1>' . $title . '</h1>';
    }
}

之后,你的页面名称将是:Foo:: Bar