I was trying to add a block to the head in magento backend for a specific controller action.

public function updateAction(){

    $block = $this->getLayout()->createBlock(
            'template' => 'namespace/update/head/data.phtml'

     * @var Mage_Adminhtml_Block_Page_Head
    $head =$this->getLayout()->getBlock('head');

However nothing is output in the head

If I use getBlock('content') or getBlock('js') instead of getBlock('head') for example it works fine but outputs the text at the content area as expected or at the end of body.

If I try $head->addCss() or $head->addJs() they both work fine too and I can add specific js or css files but I can't append a block template.

Could anyone explain to me why it's not loading the block and how to properly load it if possible?

Thanks in advance

1 Answer 1


Admin head block won't automatically render and display all its children.

You need to go to head template app/design/adminhtml/default/default/template/page/head.phtml and add:

<?php echo $this->getChildHtml('namespace_update_form_head_data') ?>  
  • I see, thank you for clarifying. Would you happen to know if there is a way to force rendering that block without altering the adminthml template file, for example via an xml update?
    – gabtzi
    Commented Mar 29, 2017 at 21:39
  • that only way that comes to mind is to overwrite getCssJsHtml method and add your custom html there. Commented Mar 29, 2017 at 22:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.