I've created a custom module in Magento but the methods I have defined for my block are not working for some reason. I can create an instance of the block in a template and call the parent blocks methods but not the methods I have defined.
/app/code/local/MyCompany/Morecategories/Block/List.php
<?php
class MyCompany_Morecategories_Block_List extends Mage_Core_Block_Template
{
public function getMoreCategories() {
return 'More categories';
}
}
Then in my template file, if I run $this->getMoreCategories()
it returns null.
I've tried running get_class($this)
, and it returns MyCompany_Morecategories_Block_List
.
I've also run get_class_methods($this)
but it only returned the parent blocks methods.
I can't imagine why my methods are not working.
Edit: Here is my config.xml
file for the module:
<?xml version="1.0"?>
<config>
<modules>
<MyCompany_Morecategories>
<version>1.0.0</version>
</MyCompany_Morecategories>
</modules>
<global>
<blocks>
<morecategories>
<class>MyCompany_Morecategories_Block</class>
</morecategories>
</blocks>
</global>
</config>
Edit 2: Here is the custom layout update xml code I have for the category
<reference name="content">
<block type="morecategories/list" name="morecategories_list" template="mycompany/catalog/category/more.phtml"/>
</reference>
Best Answer
Did you update your layout xml block type? Does it work if you try: