Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New module in magento not updating layout

I am trying to create a new custom module in magento but the layout is not loading. It always load three column layout which is defined as a default in page.xml file. I think it is not considering the layout set for my module action even if it is mentioned in the config.xml file like this-

<frontend>
        <routers>
            <mynamespace_test>
                <use>standard</use>
                <args>
                    <module>Mynamespace_Test</module>
                    <frontName>test</frontName>
                </args>
            </mynamespace_test>
        </routers>  
  <layout>
          <updates>
              <test><file>test.xml</file></test>
          </updates>
      </layout>
    </frontend>

and my test.xml looks like this:-

<?xml version="1.0"?>
<layout version="0.1.0">
    <test_index_index translate="label">
        <label>Test module</label>
        <reference name="root">
            <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
        </reference>     
        <reference name="content">
            <block type="test/this" name="test.this" template="test/test.phtml" />
        </reference>
    </test_index_index>
</layout>

and my controller is defined like this:-

class mynamespace_Test_IndexController extends Mage_Core_Controller_Front_Action
{
 function indexAction()
 {
  $this->loadLayout();
        $this->renderLayout();
 }

}

Please help! what I am missing. Thanks

like image 534
Shakti Singh Avatar asked Dec 17 '25 01:12

Shakti Singh


1 Answers

Yes, I got it working. I understood the problem is not there with layout file after pointing the layout file of some other module. The thing is wrong with this is mentioning namespace while defining router for module:

I updated this block of code:-

<routers>
            <mynamespace_test>
                <use>standard</use>
                <args>
                    <module>Mynamespace_Test</module>
                    <frontName>test</frontName>
                </args>
            </mynamespace_test>
        </routers>  

to

<routers>
            <test>
                <use>standard</use>
                <args>
                    <module>Mynamespace_Test</module>
                    <frontName>test</frontName>
                </args>
            </test>
        </routers> 

and it worked fine.

Thanks.

like image 149
Shakti Singh Avatar answered Dec 19 '25 14:12

Shakti Singh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!