How to display a phtml in a backend custom menu
-
16-10-2019 - |
Pergunta
I've created a new menu on the backend, called "X" with an item called "Y". When I click on this item, it appears nowhere because I don't know how to display it. Let me show you what I have done.
In the cotroller.php I have put this:
public function indexAction()
{
$block = $this->getLayout()
->createBlock('core/text', 'example-block')
->setText(‘Hello’);
$this->_addContent($block);
$this->renderLayout();
}
For this code, if I click on the menu "Y", I get the output "Hello". Ok, but now I don't know how to call a phtml or something in order to display whatever I want.
I don’t know how to call another cms/block or something like that to watch it there. Using this code snippet:
$this->getlayout()->createBlock('cms/block')->setBlockId('my-cms')->to
Html();
(where my-cms is a cms page that I created before)
the output appears at the top, so it doesn’t work the way I want it to work.
Solução
Putting your two code snippets together, I get:
public function indexAction()
{
$block = $this->getLayout()
->createBlock('cms/block')
->setBlockId('my-cms');
$this->_addContent($block);
$this->renderLayout();
}
Have you tried this?
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange