Question

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.

Was it helpful?

Solution 2

The reason it didn't work for me was in module's config.xml:

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

I've removed _Product_View_Tierprices from block's class definition(leaving this fragment in the actual class name) and it worked.

I think that the naming here is confusing. On the one hand you're defining something inside the <class> tag, but on the other you're supposed to write a 'path' to Block classes, not the actual class name.


If someone still experiences this problem there is an interesting thread with similar issue but different solution(compiler): Magento new custom block module

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top