Search code examples
magentomagento-1.9magento-layout-xml

Create Custom layout module


Hi i just created custom module in magento and its frontend doesn't work.

The config file :

<?xml version="1.0"?>
<config>
<modules>
    <Shareino_Sync>
        <version>0.1.0</version>
    </Shareino_Sync>
</modules>

<global>
     <helpers>
        <sync>
            <class>Shareino_Sync_Helper</class>
        </sync>
    </helpers>
    <blocks>
        <sync>
            <class>Shareino_Sync_Block</class>
        </sync>
    </blocks>
</global>
<frontend>
    <routers>
        <sync>
            <use>standard</use>
            <args>
                <module>Shareino_Sync</module>
                <frontName>shareinosync</frontName>
            </args>
        </sync>
    </routers>
    <layout>
        <updates>
            <sync>
                <file>shareino_front.xml</file>
            </sync>
        </updates>
    </layout>
</frontend>

</config>

The layout file :

# File in : app/design/frontend/default/default/layout/shareino_front.xml
<layout version="0.1.0">
    <sync_index_index>
        <reference name="content">
            <block type="sync/sync" name="sync" template="sync_index.phtml" />
        </reference>
    </sync_index_index>
</layout>

And sync_index.phtml :

# file in app/design/frontend/default/default/template/sync_index.phtml
<h1>
    Test Text
</h1>

I created a block that named Sync.php

class Shareino_Sync_Block_Sync extends Mage_Core_Block_Template
{
    public function myfunction()
    {
        return "Hello tuts+ world";
    }
}

At the end my controller :

class Shareino_Sync_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction(){

            $this->loadLayout();


            $this->renderLayout();

    }
    public function testAction(){
        echo "index Action";
    }
}

I think i done every think well , but when i load the action url in browser it doesn't my layout. please help me to know my wrong.


Solution

  • you should always put your module layout files AND template files under base/default the reason is because the fallback theme mechanism of Magento first look for those files in your_package/your_theme then under your_package/default then under base/default. So if you put those files under default/default and your package is not default those files will never be found