0

I am new to magento and learning Magento Extension Development. I am trying to load phtml template from controller but it is not loading.

Here is my code: app/code/local/MasteringMagento/Example/etc/config.xml

<?xml version="1.0"?>
<config>
  <module>
    <MasteringMagento_Example>
      <version>1.0</version>
    </MasteringMagento_Example>
  </module>

  <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>

app/code/local/MasteringMagento/Example/controllers/HelloController.php

<?php

  class MasteringMagento_Example_HelloController
      extends Mage_Core_Controller_Front_Action{

      public function worldAction(){
        $this->loadLayout();
        $this->renderLayout();
      }

  }

?>

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

<?xml version="1.0"?>
<layout version="1.0">
  <example_hello_world>
    <update handle="page_two_columns_right">
  </example_hello_world>

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

</layout>

app/design/frontend/base/default/template/example/welcome.phtml

<p>Hello World</p>

Please point out that where I made mistake. Thank you

1
  • problem in your example.xml. <refrence name="content"> should be inside in <example_hello_world> this tag. Nov 17 '16 at 12:50
2

in app/design/frontend/base/default/layout/example.xml

<?xml version="1.0"?>
<layout version="1.0">
  <example_hello_world>
    <update handle="page_two_columns_right">


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

</layout>
4
  • what is the problem in this file? I trie but did not work. Nov 17 '16 at 12:43
  • Did you flushed Magento Cache after making the changes ?
    – Cladiuss
    Nov 17 '16 at 13:13
  • replace refrence with reference in your code
    – Piyush
    Nov 17 '16 at 13:23
  • replace example.xml with my code and clear cache Nov 18 '16 at 4:34

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.