How to create a child block programmatically?

Viewed 19873

I have a page that has some template block included programmatically as follows:

public function indexAction() {
    $this->loadLayout();
    $block = $this->getLayout()
        ->createBlock('core/template')
        ->setTemplate('somefolder/sometemplate.phtml');
    
    $this->getLayout()->getBlock('content')->append($block);
    $this->renderLayout();

}

I would like to put inside the sometemplate.phtml, $this->getChildHtml('somechild') to insert another block.

I tried

$box = $this->getLayout()
->createBlock('page/html')
->setTemplate('somefolder/somechild.phtml');
$block->append($box);

But it didn't work. How can I do it?

2 Answers
Related