0
votes

I'm calling my custom module block in cms page using

{{block type="customreviews/reviews" name="customreviews_reviews" template="Customreviews/reviews.phtml"}}

My module config file is as follows:

<config>
<modules>
    <Suave_Customreviews>
        <version>0.0.1</version>
    </Suave_Customreviews>
</modules>

<global>
    <models>
        <customreviews>
            <class>Suave_Customreviews_Model</class>
        </customreviews>
    </models>
    <blocks>
        <customreviews>
            <class>Suave_Customreviews_Block</class>
        </customreviews>
    </blocks>
    <herlps>
        <customreviews>
            <class>Suave_Customreviews_Helper</class>
        </customreviews>
    </herlps>
</global>

<frontend>
    <routers>
        <customreview>
            <use>standard</use>
            <args>
                <module>Suave_Customreviews</module>
                <frontName>customreviews</frontName>
            </args>
        </customreview>
    </routers>
    <layout>
        <updates>
            <customreviews>
                <file>Customreview.xml</file>
            </customreviews>
        </updates>
    </layout>
</frontend>

block php file which I have created in my module named Reviews.php is

class Suave_Customreviews_Model_Reviews extends Mage_Core_Block_Template

{

public function firstTenCategoryReviews()
{
    $data = Mage::getSingleton('customreviews/reviews')->firstTenCategoryReviews();
    return $data;
}

}

My magento version is 1.9.2.4 I have allowed customreviews/reviews in magento admin blocks permission but still its not working.

3
What is the content in reviews.phtml file? - Mukesh
Here is the content of review.phtml echo "123123123"; $reviews = $this->firstTenCategoryReviews(); echo '<pre>'; print_r($reviews); echo '</pre>'; - Muhammad Mannan Masood

3 Answers

1
votes

There is block class is wrong. It should be

Suave_Customreviews_Block_Reviews extends Mage_Core_Block_Template
0
votes

Please check your xml file for missing node.

<config>
<modules>
    <Suave_Customreviews>
        <version>0.0.1</version>
    </Suave_Customreviews>
</modules>

<global>
    <models>
        <customreviews>
            <class>Suave_Customreviews_Model</class>
        </customreviews>
    </models>
    <blocks>
        <customreviews>
            <class>Suave_Customreviews_Block</class>
        </customreviews>
    </blocks>
    <herlps>
        <customreviews>
            <class>Suave_Customreviews_Helper</class>
        </customreviews>
    </herlps>
</global>

<frontend>
    <routers>
        <customreview>
            <use>standard</use>
            <args>
                <module>Suave_Customreviews</module>
                <frontName>customreviews</frontName>
            </args>
        </customreview>
    </routers>
    <layout>
        <updates>
            <customreviews>
                <file>Customreview.xml</file>
            </customreviews>
        </updates>
    </layout>
</frontend>
</config>  <!-- Check if you missed this node  -->

As per the code mentioned in your config.xml file, you are missing </config> node. I am assuming you have used <?xml version="1.0"?> as first line in your xml file.

Also did you try what Suman Singh mentioned?

0
votes

After alot of googleing I found the issue.

The module name I am using is customreviews but the name of the model and the block php file I named is Reviews.php.

By default magento checks for the module and block file named as the module name.

So I renamed the model and block php file to the module name and it worked.

There was also issue with my block code as Suman Singh mentioned.

Thanks Suman for the correction.