0

I am facing a strange issue. I am getting "Invalid block type" exception for a custom block that I have created. I am using the block like this

{{block type="example/menu" name="product.menu" template="catalog/product/menulist.phtml"}}

But if I use template="catalog/product/list.phtml" no exception is thrown. I get invalid block type exception if I use template="catalog/product/menulist.phtml". I have created the menulist.phtml file in app/design/frontend/rwd/verito/template/catalog/product directory.

Again, this code also works fine without exception.

{{block type="catalog/product_list" name="product.menu" template="catalog/product/menulist.phtml"}}

I have whitelisted example/menu by adding in System/Permissions/Blocks. But I couldn't find out the missing link for the mentioned exception. What am I missing? Do I need to add anything else in catalog.xml or some other xml file?

Here is the log

2018-11-11T13:57:17+00:00 ERR (3): 
exception 'Mage_Core_Exception' with message 'Invalid block type: Abcde_Example_Block_Menu' in /home/lowplex/public_html/app/Mage.php:595
Stack trace:
#0 /home/lowplex/public_html/includes/src/__default.php(28794): Mage::throwException('Invalid block t...')
#1 /home/lowplex/public_html/includes/src/__default.php(28736): Mage_Core_Model_Layout->_getBlockInstance('example/menu', Array)
#2 /home/lowplex/public_html/includes/src/__default.php(28771): Mage_Core_Model_Layout->createBlock('example/menu', 'menu')
#3 /home/lowplex/public_html/includes/src/__default.php(28538): Mage_Core_Model_Layout->addBlock('example/menu', 'menu')
#4 /home/lowplex/public_html/includes/src/__default.php(28504): Mage_Core_Model_Layout->_generateBlock(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element))
#5 /home/lowplex/public_html/includes/src/__default.php(14265): Mage_Core_Model_Layout->generateBlocks()
#6 /home/lowplex/public_html/app/code/core/Mage/Catalog/controllers/CategoryController.php(148): Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
#7 /home/lowplex/public_html/includes/src/__default.php(14339): Mage_Catalog_CategoryController->viewAction()
#8 /home/lowplex/public_html/includes/src/__default.php(18833): Mage_Core_Controller_Varien_Action->dispatch('view')
#9 /home/lowplex/public_html/includes/src/__default.php(18363): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#10 /home/lowplex/public_html/includes/src/__default.php(21319): Mage_Core_Controller_Varien_Front->dispatch()
#11 /home/lowplex/public_html/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#12 /home/lowplex/public_html/index.php(85): Mage::run('', 'store')
#13 {main}

app/etc/modules/Abcde_All.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Abcde_Example>
            <active>true</active>
            <codePool>local</codePool>
        </Abcde_Example>
    </modules>
</config>

app/code/local/Abcde/Example/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Abcde_Example>
            <version>0.1.0</version>
        </Abcde_Example>
    </modules>
    <global>
        <blocks>
            <example>
                <class>Abcde_Example_Block</class>
            </example>
        </blocks>
    </global>
</config>

app/code/local/Abcde/Example/Block/Menu.php

<?php
class Abcde_Example_Block_Menu extends Mage_Core_Block_Template {
} 

app/design/frontend/rwd/verito/template/catalog/product/menulist.phtml

<?php
/**
 * Product list template
 *
 * @see Mage_Catalog_Block_Product_List
 */
?>
<h1>Hello World!</h1>
4
  • Is there typo in block file name, or you really defined it with .xml extension. It must have .php extension. Nov 12, 2018 at 1:59
  • Its .php file. I have updated in the question.
    – souravb
    Nov 12, 2018 at 5:36
  • In app/etc/modules it should be Abcde_Example.xml Nov 12, 2018 at 6:48
  • @RohanHapani Thanks. But getting the same issue after renaming the file.
    – souravb
    Nov 12, 2018 at 8:22

1 Answer 1

0

app/code/local/Abcde/Example/block/Menu.php -> block folder first letter B must be capital. So it is like Block

1
  • Sorry. That was a typo. It is "Block". Have updated the question.
    – souravb
    Nov 12, 2018 at 6:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.