无法在Zend MVC中看到布局主页

时间:2011-12-16 10:58:11

标签: php zend-framework bootstrapping

当我在bootstrap.php

中添加此代码时
Zend_Layout::startMvc(APPLICATION_PATH . '/layouts/scripts');
$view = Zend_Layout::getMvcInstance()->getView();
        unset($view);

为什么不在我的主页上显示“hello world”?

应用/视图/脚本/索引/ index.phtml

<p> Hello World </p>

应用/布局/脚本/ layout.phtml

<?php $this->doctype();?>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<?php $this->layout()->content; ?> 
</body>
</html>

公共/ index.php的

   <?php
error_reporting(E_ALL || E_STRICT);
// Identify the location of the application directory in respect to
// the bootstrap file's location, and configure PHP's include_path to
// include the library directory's location
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application/'));
set_include_path(
APPLICATION_PATH . '/../library'. PATH_SEPARATOR . get_include_path()
);
// Give the Zend Framework the ability to load classes on demand,
// as you request them, rather than having to deal with require() statements.
require_once "Zend/Loader.php";
Zend_Loader::registerAutoload();

// Retrieve the bootstrap.php file
try {
require '../application/bootstrap.php';
} catch (Exception $exception) {
printf("Could not locate bootstrap.php");
exit(1);
}
// Start using the front controller in order to route URL requests
Zend_Controller_Front::getInstance()->dispatch();

应用/ bootstrap.php中

 <?php
// Configure the site environment status.

defined('APPLICATION_ENVIRONMENT')
or define('APPLICATION_ENVIRONMENT', 'development');
// Invoke the front controller
$frontController = Zend_Controller_Front::getInstance();
// Identify the location of the controller directory
$frontController->setControllerDirectory(APPLICATION_PATH . '/controllers');
// Create the env parameter so you can later access the environment
// status within the application.
$frontController->setParam('env', APPLICATION_ENVIRONMENT);
  // view and layout setup
  // Layout Configuration
Zend_Layout::startMvc(APPLICATION_PATH . '/layouts/scripts');
$view = Zend_Layout::getMvcInstance()->getView();
        unset($view);
  //      $view->headTitle()->setSeparator(' - ');
//        $view->headMeta()->appendHttpEquiv('Content-Language', 'en-US');
// Clean up allocated script resources
unset($frontController);

公共/ htaccess的

    RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

1 个答案:

答案 0 :(得分:0)

您没有在layout.phtml中回显您的$this->layout()->content;细分。试试吧。

编辑:我看到你没有回应你的doctype()。就核心ZF而言,没有被打印,但返回。这样,选择如何处理该值(打印,返回,存储,缓存,丢弃等)。我会给你的倾向一个名字:“wordpress期望”。