0

As per the Zend Framework standard, I'm using Zend_Layout.

 zf create project demo
 cd demo
 zf enable layout

That's it

Here's my config:

[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

Here's the situation in layout.phtml:

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

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


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

    </head>

Outputs:

<!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>

My problem is, all line breaks and white lines are removed. How can I get them back?

But, outputs of "echo $this->layout()->content" are ok(line breaks and white line still there).

Lance
  • 30
  • 4
  • Those are not removed by Zend nor PHP in your case. Most probably those are removed by the program you view the source with. Just configure your system to properly handle line breaks and you should be fine, probably UNIX or OSX linebreaks but you view the source in a windows editor? – hakre Dec 01 '11 at 16:21
  • @hakre I view source in VIM of unbutu. – Lance Dec 01 '11 at 16:38

2 Answers2

0

setIndent() , setPostfix() and not caring too much about the indenting and new lines seems to be the answer(don't like that though).

setIndetn() and setPostfix() are somewhat explained in their manual (the helpers inherit these methods from the class PlaceHolder);

Usage example (causing not-so-nice html-source/-code):

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

for reference sake; among other pages, i read(parts of):

.

Community
  • 1
  • 1
imme
  • 598
  • 1
  • 9
  • 22
0
<?= $this->doctype() ?>

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

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

</head>

Just add empty line after view helpers.

balkon_smoke
  • 1,136
  • 2
  • 10
  • 25
  • This does not explain the missing linebreak after html and before head, so I guess this isn't a solution. – hakre Dec 01 '11 at 16:22
  • One time it helps me to solve the same issue, so I just share some experiences – balkon_smoke Dec 01 '11 at 16:26
  • it can solve a similar issue, but I think it's not the one the OP has, that's all. – hakre Dec 01 '11 at 16:27
  • 1
    disappeared line breaks is not the problem considering that we're talking about result HTML. – balkon_smoke Dec 01 '11 at 16:31
  • @balkon_smoke $this->doctype() . PHP_EOL is better, but my problem is white lines are also removed. I thinks it's some kind of zend filter remove them. – Lance Dec 01 '11 at 16:39
  • @balkon_smoke I have updated question's content, please check it. Actually it's a sample zend project, I created it by zf.sh(zend command line tool). command 1: zf create project demo, then commant 2: cd demo, command 3: zf enable layout. that's it – Lance Dec 01 '11 at 16:49
  • @Lance and you did nothing in the bootstrap? – balkon_smoke Dec 01 '11 at 17:05
  • @balkon_smoke there is nothing in the bootstrap. :( – Lance Dec 01 '11 at 17:11