0

根据 Zend Framework 标准,我使用的是 Zend_Layout。

 zf create project demo
 cd demo
 zf enable layout

而已

这是我的配置:

[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 = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0

resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
[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

这是layout.phtml中的情况:

<?= $this->doctype() ?>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>  
      <?= $this->headMeta(); ?>


      <?= $this->headTitle(); ?>

    </head>

输出:

<!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" xml:lang="en" lang="en"><head>  <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />      <title>Dashboard</title>       </head>

我的问题是,所有换行符和白线都被删除了。我怎样才能让他们回来?

但是,“echo $this->layout()->content”的输出是可以的(换行符和白线仍然存在)。

4

2 回答 2

0
<?= $this->doctype() ?>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>  
  <?= $this->headMeta(); ?>

  <?= $this->headTitle(); ?>

</head>

只需在查看助手后添加空行。

于 2011-12-01T16:21:20.870 回答
0

setIndent() , setPostfix() 并且不太关心缩进和换行似乎是答案(虽然不喜欢那样)。

setIndetn() 和 setPostfix() 在他们的手册中有一些解释(助手从类 PlaceHolder 继承这些方法);

用法示例(导致不太好的 html-source/-code):

<?php echo $this->doctype(); ?>
<html>
<头部>
<?php
echo $this->headMeta()->setIndent( ' ' )->setPostfix( "\n" );
echo $this->headTitle()->setIndent( ' ' )->setPostfix( "\n" );
# ...

供参考;在其他页面中,我阅读(部分):

.

于 2012-08-14T16:07:39.527 回答