0

I'm creating a block, and I wish it to have several child blocks that appear prior to the rendering of my main block.

Following the standards set in other, inherited classes, I can see the following:

public function _prepareLayout() { $this->setChild('alias', $this->getLayout()->createBlock('modulename/block_name') ); return parent::_prepareLayout(); } 

If I follow the path to the parent _prepareLayout() function, it appears in exactly the same format. In addition, if I print out the $this->_children variable after the layout has processed, I get a list of elements that includes mine.

However, it's not rendering to the page and I've not idea what else I need to do output it.

My blocks are loaded programatically, i.e. without a layout or template file.

2
  • You should add a template to your block or implement the _toHtml method to return something. Commented Sep 2, 2014 at 14:29
  • Excellent. I added the block to the _toHtml method and it's all working as expected. If you add this as an answer with a bit of code, I'll mark you correct! Commented Sep 2, 2014 at 14:32

1 Answer 1

1

In order to view a block in the layout it fit in one of the 2 cases:

  • it has a _toHtml method that returns something
  • it extends Mage_Core_Block_Template and has a valid template associated.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.