根据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-&gt; layout() - &gt; content”的输出还可以(换行符和白线仍然存在)。
答案 0 :(得分:0)
<?= $this->doctype() ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<?= $this->headMeta(); ?>
<?= $this->headTitle(); ?>
</head>
在视图助手后添加空行。
答案 1 :(得分:0)
setIndent(),setPostfix()并没有过多关注缩进和新行似乎是答案(虽然不喜欢)。
setIndetn()和setPostfix()在他们的手册中有所解释(帮助者从PlaceHolder类继承这些方法);
用法示例(导致不太好的html-source / -code):
<?php echo $this->doctype(); ?> <html> <head> <?php echo $this->headMeta()->setIndent( ' ' )->setPostfix( "\n" ); echo $this->headTitle()->setIndent( ' ' )->setPostfix( "\n" ); # ...
供参考;在其他页面中,我读过(部分):