0

I am using Magento 1.7. The namespace is called MasteringMagento with a module called example.

My index controller is like so:

class MasteringMagento_Example_IndexController extends Mage_Core_Controller_Front_Action {

    function indexAction() 
    {
        $this->loadLayout();

        return $this->renderLayout();
    }

}

If inside the indexAction I put an echo statement for example, it works, but it won't display a .phtml file.

config.xml (inside app/code/local/MasteringMagento/example/etc

<?xml version ="1.0"?>
<!DOCTYPE config>

<config>

    <modules>
        <MasteringMagento_Example>
            <version>0.0.0</version>
        </MasteringMagento_Example>
    </modules>

    <global>
        <models>
            <example>
                <class>MasteringMagento_Example_Model</class>
            </example>
        </models>
        <blocks>
            <example>
                <class>MasteringMagento_Example_Block</class>
            </example>
        </blocks>
        <helpers>
            <example>
                <class>MasteringMagento_Example_Helper</class>
            </example>
        </helpers>
    </global>

    <frontend>
        <routers>
            <example>
                <use>standard</use>
                <args>
                    <frontName>example</frontName>
                    <module>MasteringMagento_Example</module>
                </args>
            </example>
        </routers>
        <layout>
            <updates>
                <example>
                    <file>example.xml</file>
                </example>
            </updates>
        </layout>
    </frontend>

</config>

example.xml (inside app/design/frontend/base/default/layout

<?xml version ="1.0"?>
<!DOCTYPE config>

<layout version="0.1.0">
    <example_index_index>
        <update handle="page_two_columns_right" />

        <reference name="content">
            <block type="core/template" template="example/welcome.phtml">
        </reference>
    </example_index_index>
</layout>

And I have a folder called example with a welcome.phtml file inside located in app/design/frontend/base/default/template

What am I missing?

EDIT:

If I remove

<reference name="content">
            <block type="core/template" template="example/welcome.phtml">
        </reference>

from example.xml

I get a blank content area, but if it's there I get the dog, the tags and newsletter update column, not sure if that makes a difference.

1

You might need to close your block tag

<block type="core/template" template="example/welcome.phtml"/>
0

I'm not a 100% sure right now but i think your block needs a unique name for it to be instantiated

<block type="core/template" name="example.index.welcome" template="example/welcome.phtml">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.