1
votes

So I have been searching the internet for hours now and I can't figure this out.

I wrote a custom Magento Module that has a custom index page, which works fine on one Magento install (1.5.0.1) but not on another (1.5.1.0). The problem is that my custom template file does not get included when I go to the module's main URL (domain.com/module).

So Far, I know this:

  • The Layout XML is included when the page is built (because I get errors in system.log if I deliberately mess up the syntax)
  • If I include var_dump($this->getLayout()->getUpdate()->getHandles()); in my IndexController.php I can see that:
    1) my IndexController is called, so that must be okay and
    2) The handle for my module is called and has the exact same name I specified in my layout XML file.
  • The template file is not called. I know because it should throw a Magento exception if it is (I included a non-existent function call on an object in that template file for testing purposes).
  • If I change <block type="identifier/action" to <block type="core/template" in the layout XML file, the template file is included, but of course it will not work properly because the block functions from the custom module are not defined.

  • I have absolutely no idea where I could look next, so any help would be greatly appreciated. I know it must be something simple because it works flawlessly on the other Magento install...
    1
    You should consider buying @Alan Storm's Commercebug extension. It's the best $50 I've spent in a long time. It really helps show exactly which blocks and template files are being loaded. - Joe Constant

    1 Answers

    5
    votes

    My guess would be the class alias identifier/action doesn't resolve correctly to a PHP/Magento block class. Check your Magento Exception log (var/log/exception.log, logging needs to be enabled in the Admin Console) and you'll probably see some errors related to "Invalid block type".

    Try running

    $block = $this->getLayout()->createBlock('identifier/action');
    var_dump($block);
    if($block)
    {
        $block->setTemplate('path/to/template.phtml');
        var_dump($block->toHtml());   
    }    
    

    from a PHP context (a controller action) and check that your block is actually being instantiated. It's also worth checking that your template file actually exists in your theme, and that your custom block inherits from a template block.