Thursday, September 24, 2015

Magento - block not loading (2)

Magento is very case sensitive! While developing your modules / extensions, the best practice to use is to use only the first capital letter in your extension or company name.


Example of bad practice:
GogiProductions_CMSubtotal

Example of good practice:
Gogi_Cmsubtotal

The reason is in the way Magento parses the filenames. It interprets each capital letter as a new folder!

Also, make sure you reference your blocks in the way you choosed in config.xml file.

For example, if this is your config.xml (part of it):



             <blocks>
                  <cmsubtotals>
                        <class>Gogi_Cmsubtotals_Block</class>
                  </cmsubtotals>
               
             
            </blocks>


Then , in your layout.xml ([yourextensionname].xml), you should reference your blocks like this:



    <adminhtml_sales_order_creditmemo_new>
     
 
            <reference name="creditmemo_totals">
                <block type="cmsubtotals/cmsubtotal" name="cmsubtotal" template="cmsubtotals/cmsubtotals.phtml"/>
            </reference>
     

    </adminhtml_sales_order_creditmemo_new>

Pleaase note we use block type with reference to the setting in our config.xml.

No comments:

Post a Comment

Ubuntu 12.04, 14.04, 16.04 - auto start an app or script before login

To run a command or application at startup, even before the user has logged in, you can use this file: /etc/rc.local The commands entered...