Shashi
Shashi

Reputation: 1235

Layout does not load in Custom module of Magento

I am writing a custom module for magento and having some problems here. My layout xml does not work. even i am not getting any exception or log. I have also try it after cache flushing and re-indexing through admin panel. hello message is printed which is put under IndexController.php but layout doesnot load.

The layout xml file is put under /var/www/magento/app/design/frontend/default/default/layout/wsplugin.xml

config.xml

<?xml version="1.0"?>
<config>
   <modules>
          <NAMESPACE_WSPlugin>
                 <version>0.1.0</version>   
                 <depends>
                        <Mage_Catalog />
                 </depends>
          </NAMESPACE_WSPlugin>
   </modules>
   <frontend>
          <routers>
                 <wsplugin>
                        <use>standard</use>
                        <args>
                               <module>NAMESPACE_WSPlugin</module>
                               <frontName>wsplugin</frontName>  
                        </args>
                 </wsplugin>
          </routers>
          <layout>
                 <updates>
                        <wsplugin>
                               <file>wsplugin.xml</file>
                        </wsplugin>
                 </updates>
          </layout>
   </frontend>
   <global>
          <blocks>
                 <wsplugin>
                         <class>NAMESPACE_WSPlugin_Block</class>  
                 </wsplugin>
          </blocks>
          <helpers>
                 <wsplugin>
                        <class>NAMESPACE_WSPlugin_Helper</class> 
                 </wsplugin>
          </helpers>
   </global>
</config>

IndexController.php

<?php
 class NAMESPACE_WSPlugin_IndexController extends Mage_Core_Controller_Front_Action {
     public function indexAction() {
      $this->loadLayout(); 
          $this->renderLayout();
          echo 'hello message';
     }
}
?>

WSPlugin.php(Under NAMESPACE/WSPlugin/Block)

<?php
   class NAMESPACE_WSPlugin_Block_WSPlugin extends Mage_Core_Block_Template {
    public function getWSPlugin() {
    return "get WS Plugin under Block";
    }
   }

wsplugin.xml

<?xml version="1.0"?>
<layout version="0.1.0">
<default>
       <reference name="content">
       </reference>
</default>
   <wsplugin_index_index>
       <reference name="content">
            <block type="wsplugin/wsplugin" name="wsplugin" template="wsplugin/wsplugin.phtml" />
        </reference>
   </wsplugin_index_index>
</layout>

wsplugin.phtml

<h4><?php echo 'Welcome in WS Plugin';
   echo $this->getWSPlugin();
?></h4>

Upvotes: 2

Views: 4270

Answers (3)

Ataboy Josef
Ataboy Josef

Reputation: 2101

It's the problem of your layout's handle tag.

Please take a look at the below example:

<?xml version="1.0"?>
<layout version="0.1.0">
    <mymodule_adminhtml_mymodule_index>
        <reference name="content">
            <block type="mymodule/adminhtml_mymodule" name="mymodule" />
        </reference>
    </mymodule_adminhtml_mymodule_index>
</layout>

Please, try the above format!

Upvotes: 1

peter gunn
peter gunn

Reputation: 456

In your layout file wsplugin.xml you should use

<block type="core/template" name="wsplugin" template="wsplugin/wsplugin.phtml" />

Upvotes: 0

sebastianwagner
sebastianwagner

Reputation: 409

Just to be sure did you place an module XML file under app/etc/modules/NAMESPACE_WSPlugin.xml?

<config>
    <modules>
                <NAMESPACE_WSPlugin>
                        <active>true</active>
                        <codePool>community</codePool>
                </NAMESPACE_WSPlugin>
        </modules>
</config>

Also check that your Module appears under System->Configuration->Advanced->Advanced->Disable Modules Output

It is also better to place your layout under app/design/frontend/base/default.

Upvotes: 0

Related Questions