-4

I'm making a new page controller in my store, but the current configuration does not load the new block on the page. What is the probable error? And yes, I cleared the cache, and are disabled. The referent of my config.xml code is:

<Frontend>
        <Routers>
            <Helloworld>
                <Use>standard </use>
                <Args>
                    <Module>ITEP_Incomm </module>
                    <FrontName>helloworld</frontName>
                </Args>
            </Helloworld>
        </Routers>
</Frontend>

        <Blocks>
            <InComm>
                <Class>ITEP_Incomm_Block </class>
            </InComm>
       </Blocks>

Ok ... now the controller code (IndexController.php):

<?php

ITEP_Incomm_IndexController class extends Mage_Core_Controller_Front_Action {
    indexAction public function () {    $This->loadLayout()->getLayout()->getBlock(root)->setTemplate('page/1column.phtml');
$ This-> renderLayout ();
    }
}

The block.php code:

<?php
ITEP_Incomm_Block class extends Mage_Core_Block_Template
{

}

And the call in my file the theme folder / layout / incommmenu.xml is:

<?xml version = "1.0" encoding = "UTF-8"?>
<Layout>
    <ITEP_Incomm_index_index>
            <Block type="InComm/block" name="newreferenceBlock" template="test/example.phtml" />
    </ ITEP_Incomm_index_index>
</Layout>

When access localhost:8080/magento/helloworld / my theme carries the top menu and footer, but the content is empty, my block did not load. What's wrong? Thank you.

1 Answers1

6

I can see a lot of mistakes in those codes. Before showing you each and every one, I would like to show you how should those codes should appear.

File : app\code\local\ITEP\Incomm\etc\config.xml

<config>
    <modules>
        <ITEP_Incomm>
            <version>1.0.0</version>
        </ITEP_Incomm>
    </modules>
    <frontend>
        <routers>
            <itep_incomm>
                <use>standard</use>
                <args>
                    <module>ITEP_Incomm</module>
                    <frontName>helloworld</frontName>
                </args>
            </itep_incomm>
        </routers>
        <layout>
            <updates>
                <itep_incomm>
                     <file>incommmenu.xml</file>
                </itep_incomm>
            </updates>
        </layout>
    </frontend>
    <global>
        <blocks>
            <itep_incomm>
                <class>ITEP_Incomm_Block</class>
            </itep_incomm>
        </blocks>
    </global>
</config>

File : app\code\local\ITEP\Incomm\controllers\IndexController.php

<?php
class ITEP_Incomm_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
        $this->loadLayout();
        $this->renderLayout();
    }
}

File : app\code\local\ITEP\Incomm\Block\Hello.php

<?php
class ITEP_Incomm_Block_Hello extends Mage_Core_Block_Template
{

}

File : app\design\frontend\base\default\layout\incommmenu.xml

<layout>
    <itep_incomm_index_index>
        <reference name="root">
            <action method="setTemplate">
                <template>page/1column.phtml</template>
            </action>
        </reference>
        <reference name="content">
            <block type="itep_incomm/hello" name="helloworld.block" template="test/example.phtml" />
        </reference>
    </itep_incomm_index_index>
</layout>

File : app\design\frontend\base\default\template\test\example.phtml

<h2>Hello World</h2>
<p> Welcome to the Magic world of Magento. </p>

File : app\etc\modules\ITEP_Incomm.xml

<config>
    <modules>
        <ITEP_Incomm>
            <active>true</active>
            <codePool>local</codePool>
        </ITEP_Incomm>
    </modules>
</config>

You are done. Now clear the cache and try to load the page www.your-domain.com/helloworld and most probably you can see the result.

The Mistakes That You Have Done

  • Basically almost all node that magento provides in default configurations are lower-cased nodes. Basically <block /> node is not equal to <Block />. Both are different for magento.

  • You are using camel-case letter in every page and in every file as the first letter. This is wrong. You should stick with basic rules. ie I am not equal to i am for Magento.

  • You are using unwanted spaces everywhere and it is again wrong.

  • You are even declaring classes wrongly !

  • I didn't understand what is this <? Php ?

What You Need To Do

  • You should study basics of PHP first

  • Then you should study basics of Magento.

  • Then you should study how extensions are developing in Magento.

  • Then you should put your Magento instance in developer mode and then play with it.

  • Next time, please avoid to ask such awkward questions here.

EDIT

I have created this extension for your reference.I checked this in my Magento instance and it is working perfectly. So use this as your reference.

Rajeev K Tomy
  • 17,234
  • 6
  • 61
  • 103
  • block not load yet, I plan to study yes (I already have a php book purchased =)) but I thoroughly analyzed the code, Upper and lower and referring to the block code appears to be correct. I wonder what the error to avoid future uncertainties ,Thanks <itep_incomm> <class>ITEP_Incomm_Block</class> </itepincomm>

    `<fourward_incomm_index_index> ...

    ` The layout is being loaded (because 1column is in xml only), less the portion relating to the block
    – Matheus Silva Itep May 27 '15 at 05:56
  • This code works perfectly. I checked it now. Please have a look on this thread first http://magento.stackexchange.com/questions/56396/how-to-create-a-custom-block-in-custom-module and checkout my answer over there. Also I have created this module for reference. Have a look on the edit section of my answer – Rajeev K Tomy May 27 '15 at 07:40