ANisus ANisus - 2 years ago 79
PHP Question

Set indent on view in Zend Framework

In Zend Framework, it is possible to set indentation for headMeta(), headLink(), etc:

<?= $this->headLink()->setIndent("\t\t") ?>

I like this. I like things tidy. So, now I would want to indent my entire view as well in the layout.phtml file, causing every new line in the view script to be indented with X tabs.

<?= $this->layout()->setIndent("\t\t")->content ?>

This does not work. Is there any way to do this within Zend Framework without having to intercept the output with ob_start?

Answer Source

Zend_Layout has no setIndent(), check here: You have to take care of the indentation by yourself in your template.

A generic solution would be to use Tidy with Zend Framework. The options to use then would be

indent => true
indent-spaces => 4
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download