Problems with Zend layout

Asked

Viewed 256 times

5

I have a view that is formed by a layout different from the pattern in my project, Seto it this way:

public function init() {
    //Colocando o layout default
    $this->_helper->layout->setLayout('layout_paginas');
}

But the content of this layout, is simply ignored, only the view content is loaded, someone knows what might be happening?

I am editing here by the following: All actions of this controller work normally, only one specific does not load layout content.

  • You could then post these actions?

2 answers

3

By the content of your question I don’t know if you’re taking into account the path to the layout:

 $layout->setLayoutPath('caminho/para/o/layout');

But you can also change your code to:

$this->_helper->layout->setLayout('/caminho/para/o/layout/layout_paginas');

Notes:
The path to the file is relative to the layouts folder, which by default is located in application/layouts/scripts/.


If you’re using:

$this->_helper->layout->setLayout('layout_paginas');

Actually, you’re saying to look up the layout on:

application/layouts/scripts/layout_paginas.phtml

Aids:

  • Yes, it is in application/layouts/scripts/layout_paginas.phtml

2


Try it like this:

// Usar o layout layout_paginas.phtml como padrão
Zend_Layout::getMvcInstance()->setLayout('layout_paginas');

Otherwise, use the same way you did, but informing the relative layout path:

// Neste caso, o diretório padrão é esse: application/layouts/scripts/
$this->_helper->layout->setLayout('application/layouts/scripts/layout_paginas.phtml');
  • I can not use it as default, because I also already use the default...so to say...

  • @Kennyrafael anyway, I’m sure it works. Just enter this code into your specific action (the one that isn’t working). OR init() test-only.

  • Obricado, for this case was solved in this way...

  • @Kennyrafael Which of the methods resulted to resolve the issue? Define the layout through the getMvcInstance() or applying the path in the method setLayout() (for future reference)?

  • Applying the path in setLayout()

Browser other questions tagged

You are not signed in. Login or sign up in order to post.