Magento module - redefines the controller, adds templates

I am currently working on a Magento extension, and I have redefined the main controller, which works great.

Now I have added a new action for my controller. The problem is that whenever I invoke an action, a blank page is created. If I repeat something, it displays correctly.

So I dug up the core of the Customer module and controllers. I saw that methods like indexAction()implement the layout like this:

<?php
public function indexAction()
{
  $this->loadLayout();
  $this->_initLayoutMessages('customer/session');
  $this->_initLayoutMessages('catalog/session');

  $this->getLayout()->getBlock('content')->append(
      $this->getLayout()->createBlock('customer/account_dashboard')
  );
  $this->getLayout()->getBlock('head')->setTitle($this->__('My Account'));
  $this->renderLayout();
}

I transferred this to my action and the layout now displays correctly. Now to the question:

No matter what I enter the call ->createBlock('...'), nothing is displayed in the content area.

, , ?

xml /design/frontend/base/default/layout/myaddon.xml, .

+3
1

Magento StackOverflow , , , .

    $block = $this->getLayout()->createBlock('Mage_Core_Block_Text');
    $block->setText('<h1>This is a Test</h1>');
    $this->getLayout()->getBlock('content')->append($block);

, , . , , . ( Mage_Core_Block_Text) phtml ( HTML ).

, , .

+6

Source: https://habr.com/ru/post/1735623/


All Articles