Custom Module’s Block Not Showing – XML Layout File ‘Type’ Issue in Magento

blockscustom block

Block created inside custom module doesn't show up in the fron-end.

Namespace: Fmat

Module: FtPrices

Custom Block file: Fmat/FtPrices/Block/Product/View/Tierprices.php


custom block php file:

<?php
 class Fmat_FtPrices_Block_Product_View_Tierprices extends Mage_Core_Block_Template {
 }
?>

block's definition in module's config.xml (…etc/config.xml)

<global>
(...)
    <blocks>
        <fmat_ftprices>
            <class>Fmat_FtPrices_Block_Product_View_Tierprices</class>
        </fmat_ftprices>
    </blocks>
</global>

in module's layout file:

<catalog_product_view>
    <reference name="product.info">
        <block type="fmat_ftprices/product_view_tierprices" name="product.custom.tierprices" as="custom_tierprices" template="fmat/ftprices/product/view/tierprices.phtml"/>
    </reference>
</catalog_product_view>

in catalog/product/view.phtml I get the block via:

echo $this->getChildHtml('custom_tierprices');

Once I change block type in module's layout file from type="fmat_ftprices/product_view_tierprices" to type="catalog/product_view" the template shows up in the front end. Can you see any errors in my files?

I'd appreciate your input.

Best Answer

Personally I struggle to get any module to work when the module name has CamelCase in it. FtPrices probably resolves to ft/prices at some point. Therefore my suggestion is to go through your module files and replace FtPrices with Ftprices. After that the filenames/paths with 'FtPrices' will need to be 'Ftprices'.

By tidying up the CamelCase ambiguities I think your module will work as you want - seems you know your stuff and know what to post for a meaningful question.

Related Topic