0

I have a custom module. I need to add it in home page of my site. I have added block in the content section of my home page. But it didn't display anything. I have also tried the layout part of home page and the result is as in the previous case. These are my codes

app/code/local/Karaokeshop/Banner/etc/config.xml

<config>
<modules>
    <Karaokeshop_Banner>
        <version>0.1.0</version>
    </Karaokeshop_Banner>
</modules>
<frontend>
    <routers>
        <banner>
            <use>standard</use>
            <args>
                <module>Karaokeshop_Banner</module>
                <frontName>banner</frontName>
            </args>
        </banner>
    </routers>
    <layout>
        <updates>
            <banner>
                <file>banner.xml</file>
            </banner>
        </updates>
    </layout>
</frontend>
<admin>
    <routers>
        <banner>
            <use>admin</use>
            <args>
                <module>Karaokeshop_Banner</module>
                <frontName>banner</frontName>
            </args>
        </banner>
    </routers>
</admin>
<adminhtml>
    <menu>
       <!-- <banner module="banner">-->
       <cms>
            <title>CMS</title>
            <sort_order>71</sort_order>
            <children>
                <items module="banner">
                    <title>Manage Banner</title>
                    <sort_order>0</sort_order>
                    <action>banner/adminhtml_banner</action>
                </items>
            </children>
        </cms>
        <!--</banner>-->
    </menu>
    <acl>
        <resources>
            <all>
                <title>Allow Everything</title>
            </all>
            <admin>
                <children>
                    <Karaokeshop_Banner>
                        <title>Banner Module</title>
                        <sort_order>10</sort_order>
                    </Karaokeshop_Banner>
                </children>
            </admin>
        </resources>
    </acl>
    <layout>
        <updates>
            <banner>
                <file>banner.xml</file>
            </banner>
        </updates>
    </layout>
</adminhtml>

<global>
    <models>
        <banner>
            <class>Karaokeshop_Banner_Model</class>
            <resourceModel>banner_mysql4</resourceModel>
        </banner>
        <banner_mysql4>
            <class>Karaokeshop_Banner_Model_Mysql4</class>
            <entities>
                <banner>
                    <table>banner</table>
                </banner>
            </entities>
        </banner_mysql4>
    </models>
    <resources>
        <banner_setup>
            <setup>
                <module>Karaokeshop_Banner</module>
            </setup>
            <connection>
                <use>core_setup</use>
            </connection>
        </banner_setup>
        <banner_write>
            <connection>
                <use>core_write</use>
            </connection>
        </banner_write>
        <banner_read>
            <connection>
                <use>core_read</use>
            </connection>
        </banner_read>
    </resources>
    <blocks>
        <banner>
            <class>Karaokeshop_Banner_Block</class>
        </banner>
    </blocks>
    <helpers>
        <banner>
            <class>Karaokeshop_Banner_Helper</class>
        </banner>
    </helpers>
</global>
</config>

This is the code I have tried in the content section of home CMS page

{{block type="banner/banner" name="home_banner" template="banner/homenewpro.phtml"}}

This is the code I have tried in the layout part(within content section) of home CMS page.

<block type="banner/banner" name="home_banner" template="banner/banner.phtml" />

What is the problem with this code? What I have made wrong with these codes? Help me guys.... Thanks in advance..

3
  • Check the banner.xml file in your template folder
    – Keyul Shah
    Jan 24, 2014 at 3:21
  • @KeyulShah i have tried this code <layout version="0.1.0"> <banner_index_index> <reference name="root"> <action method="setTemplate"> <template>page/1column.phtml</template> </action> </reference> <reference name="content"> <block type="banner/banner" name="home_banner"> </block> </reference> </banner_index_index> </layout> when i look into the page, the page layout become 1column. however content block is not displaying. my phtml file echo 'test' in it. Jan 24, 2014 at 3:43
  • i have also tried this <block type="banner/banner" name="home_banner" template="banner/banner.phtml"/> and this <block type="banner/banner" name="home_banner" />. still not displaying the content Jan 24, 2014 at 3:46

2 Answers 2

1

First of all make sure the file Karaokeshop/Banner/Block/Banner.php exists and contains this class.

class Karaokeshop_Banner_Block_Banner extends Mage_Core_Block_Template{
   //class methods here
}

also make sure the template banner/homenewpro.phtml exists in app/design/frontend/{package}/{theme}/template.
Just to make sure, you can place it in app/design/frontend/base/default/template.

I hope you also created the declaration file app/etc/modules/Karaokeshop_Banner.xml with this content.

<?xml version="1.0"?>
<config>
    <modules>
        <Karaokeshop_Banner>
            <codePool>local</codePool>
            <active>true</active>
            <depends>
                <Mage_Core />
            </depends>
        </Karaokeshop_Banner>
    </modules>
</config>

Clear the cache, disable the compilation and give it an other try.

You can also enable the logging from System->Configuration->Developer and check var/log for any errors.

0

Is your template file including only <?php echo "test"?>....? If so then try adding some HTML tags in it like "div". As you see in other magento template files, A phtml file is a combo of both HTML and PHP. So edit your phtml file accordingly and give it a try.

Your Answer

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

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