这项工作:使用zend工具创建一个新项目后由我在本地测试!
//应用程序.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"); ?>
//创建视图/helper/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