0
votes

I'm pretty new to Magento and I've started learning to develop custom modules for the frontend. I've followed several guides and for some reason, none of them are working. It seems as though loadLayout and renderLayout are causing problems. I'm not sure if this is because I have a file in the wrong location, or what the problem is. I've tried loading the pages magento.x/helloworld magento.x/helloworld/index magento.x/index.php/helloworld. I'm getting a broken version of the default site. If I replace the lLayout and rLayout with an echo it works just fine. This is what I have:

app/code/local/Wrapids/Helloworld/etc/config.xml

<config>
<modules>
    <Wrapids_Helloworld>
        <version>0.1.0</version>
    </Wrapids_Helloworld>
</modules>
<frontend>
    <routers>
        <helloworld>
            <use>standard</use>
            <args>
                <module>Wrapids_Helloworld</module>
                <frontName>helloworld</frontName>
            </args>
        </helloworld>
    </routers>
    <layout>
        <updates>
            <helloworld>
                <file>helloworld.xml</file>
            </helloworld>
        </updates>
    </layout>
</frontend>
</config>

app/code/local/Wrapids/Helloworld/controllers/IndexController.php

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

/app/design/frontend/default/default/template/helloworld/page.phtml

text

app/design/frontend/default/default/layout/helloworld.xml

<?xml version="1.0" encoding="UTF-8"?>
<layout version="0.1.0">
    <default>
        <reference name="content">
            <block type="helloworld/helloworld" name="hello" template="helloworld/page.phtml">
        </reference>
    </default>
</layout>

app/code/local/Wrapids/Helloworld/Block/Helloworld.php

<?php
    class Wrapids_Helloworld_Block_Helloworld extends Mage_Core_Block_Template
    {
    }
?>
3
You closing tag for the layout xml (app/design/frontend/default/default/layout/helloworld.xml) is broken, check if that is the issue. - Gershon Herczeg
Oops, nope. Typo when I entered it in on here. - Sturm
The problem at your layout file. First of all, you remove root node, as far as I remember it's main node. And I don't see <wrapids_helloworld_index> at layout. - Viacheslav Kondratiuk
@v.kondratyuk: I have tried wrapids_helloworld_index as well as default. Neither of them are yielding changes. As far as removing the root node it should leave me with an entirely blank page. It doesn't look like the layout.xml may even be being processed. - Sturm
make an error at helloworld.xml and check if you can see an error, also check cache. - Viacheslav Kondratiuk

3 Answers

2
votes

I do not quite understood your goal but you can try it:
app/design/frontend/default/default/layout/helloworld.xml

<layout version="0.1.0">
    <default>
        <reference name="root"> 
            <action method="setTemplate"><template>helloworld/page.phtml</template></action> 
        </reference>
    </default>
</layout> 
1
votes

Move your template and layout files to [your_package]/default or [your_package]/[your_theme]

0
votes

Have you added Wrapids_Helloworld.xml file to app/etc/modules with the following code? This must be present in order to load the module

<?xml version="1.0"?>
<config>
    <modules>
        <Wrapids_Helloworld>
            <active>true</active>
            <codePool>local</codePool>
        </Wrapids_Helloworld>
    </modules>
</config>