Magento Unable to load my custom layout through controller The Next CEO of Stack Overflowcustom layout not rendering for overridden login methodmagento can't load block via controllerNot display Front endrewrite block not workingCustom module does not display in pageCustom phtml not getting called from the Block magentoCustom table data not shown in tempalte file Magento 2How to do work with custom module Admin PanelMagento 1.9 add layout and template to custom module in adminInvalid Blocktype
Is it a bad idea to plug the other end of ESD strap to wall ground?
Read/write a pipe-delimited file line by line with some simple text manipulation
Create custom note boxes
Traveling with my 5 year old daughter (as the father) without the mother from Germany to Mexico
Ising model simulation
Is it reasonable to ask other researchers to send me their previous grant applications?
How to find if SQL server backup is encrypted with TDE without restoring the backup
MT "will strike" & LXX "will watch carefully" (Gen 3:15)?
Prodigo = pro + ago?
Masking layers by a vector polygon layer in QGIS
Why does freezing point matter when picking cooler ice packs?
Why do we say “un seul M” and not “une seule M” even though M is a “consonne”?
How to implement Comparable so it is consistent with identity-equality
How can I separate the number from the unit in argument?
Small nick on power cord from an electric alarm clock, and copper wiring exposed but intact
Calculate the Mean mean of two numbers
Why did early computer designers eschew integers?
Avoiding the "not like other girls" trope?
Could a dragon use its wings to swim?
Does int main() need a declaration on C++?
pgfplots: How to draw a tangent graph below two others?
How do I keep Mac Emacs from trapping M-`?
Man transported from Alternate World into ours by a Neutrino Detector
Does Germany produce more waste than the US?
Magento Unable to load my custom layout through controller
The Next CEO of Stack Overflowcustom layout not rendering for overridden login methodmagento can't load block via controllerNot display Front endrewrite block not workingCustom module does not display in pageCustom phtml not getting called from the Block magentoCustom table data not shown in tempalte file Magento 2How to do work with custom module Admin PanelMagento 1.9 add layout and template to custom module in adminInvalid Blocktype
I have created a module with controller and model. But I am now trying to load a custom view where I can stuff all my PHP,css,js code into that PHTML file.
Here is my Block of Code
appcodelocalSoumenTestmodulecontrollersIndexController.php
IndexController file
public function indexAction()
echo "This is default";
public function sayHelloAction()
Mage::log('im in Controller');
$this->loadLayout();
$this->renderLayout();
Zend_Debug::dump($this->getLayout()->getUpdate()->getHandles());
Config file
appcodelocalSoumenTestmoduleetcconfig.xml
<config>
<frontend>
<routers>
<Soumen_Testmodule>
<use>standard</use>
<args>
<module>Soumen_Testmodule</module>
<frontName>testmodule</frontName>
</args>
</Soumen_Testmodule>
</routers>
<layout>
<updates>
<testmodule>
<file>testmodule.xml</file>
</testmodule>
</updates>
</layout>
</frontend>
</config>
appdesignfrontendbasedefaultlayouttestmodule.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<testmodule_index_index>
<reference name="content">
<block type="testmodule/test" name="test" template="testmodule/test.phtml" />
</reference>
</testmodule_index_index>
</layout>`
appcodelocalSoumenTestmoduleBlockTest.php
class Soumen_Testmodule_Block_Test extends Mage_Core_Block_Template
public function getContent()
return "Hello World";
appdesignfrontendbasedefaulttemplatetestmoduletest.phtml
<?php echo $this->getContent();?>
Now when I call http://magento/testmodule... Then it displays the dufault page,
but should show Hello World . Can Someone help me out , that what wrong I am doing
magento-1.9 blocks
add a comment |
I have created a module with controller and model. But I am now trying to load a custom view where I can stuff all my PHP,css,js code into that PHTML file.
Here is my Block of Code
appcodelocalSoumenTestmodulecontrollersIndexController.php
IndexController file
public function indexAction()
echo "This is default";
public function sayHelloAction()
Mage::log('im in Controller');
$this->loadLayout();
$this->renderLayout();
Zend_Debug::dump($this->getLayout()->getUpdate()->getHandles());
Config file
appcodelocalSoumenTestmoduleetcconfig.xml
<config>
<frontend>
<routers>
<Soumen_Testmodule>
<use>standard</use>
<args>
<module>Soumen_Testmodule</module>
<frontName>testmodule</frontName>
</args>
</Soumen_Testmodule>
</routers>
<layout>
<updates>
<testmodule>
<file>testmodule.xml</file>
</testmodule>
</updates>
</layout>
</frontend>
</config>
appdesignfrontendbasedefaultlayouttestmodule.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<testmodule_index_index>
<reference name="content">
<block type="testmodule/test" name="test" template="testmodule/test.phtml" />
</reference>
</testmodule_index_index>
</layout>`
appcodelocalSoumenTestmoduleBlockTest.php
class Soumen_Testmodule_Block_Test extends Mage_Core_Block_Template
public function getContent()
return "Hello World";
appdesignfrontendbasedefaulttemplatetestmoduletest.phtml
<?php echo $this->getContent();?>
Now when I call http://magento/testmodule... Then it displays the dufault page,
but should show Hello World . Can Someone help me out , that what wrong I am doing
magento-1.9 blocks
Is that the entire config.xml and controller file? What do you see in your browser? Do you have a layout file? Can you post it? As this question stands, there's nowhere near enough information to start on it...
– tjons
Jan 11 '17 at 16:26
add yourtestmodule.xmlfrom layout folder and block code
– sandip
Jan 11 '17 at 16:27
<?xml version="1.0"?> <layout version="0.1.0"> <testmodule_index_sayHello> <reference name="content"> <block name="testmodule" template="newpage/content.phtml"/> </reference> </testmodule_index_sayHello> </layout>
– Soumen Kumar Saha
Jan 11 '17 at 16:27
I am able to see the default page of my theme, but I want to display the contents of my conent.phtml file , where I have added my HTML stuff
– Soumen Kumar Saha
Jan 11 '17 at 16:31
@SoumenKumarSaha for creating module you need to follow some basic steps.....as i written bellow (by Vishal Thakur). Just edit module name (Excellence_Test) as you want.
– Vishal Thakur
Jan 11 '17 at 19:19
add a comment |
I have created a module with controller and model. But I am now trying to load a custom view where I can stuff all my PHP,css,js code into that PHTML file.
Here is my Block of Code
appcodelocalSoumenTestmodulecontrollersIndexController.php
IndexController file
public function indexAction()
echo "This is default";
public function sayHelloAction()
Mage::log('im in Controller');
$this->loadLayout();
$this->renderLayout();
Zend_Debug::dump($this->getLayout()->getUpdate()->getHandles());
Config file
appcodelocalSoumenTestmoduleetcconfig.xml
<config>
<frontend>
<routers>
<Soumen_Testmodule>
<use>standard</use>
<args>
<module>Soumen_Testmodule</module>
<frontName>testmodule</frontName>
</args>
</Soumen_Testmodule>
</routers>
<layout>
<updates>
<testmodule>
<file>testmodule.xml</file>
</testmodule>
</updates>
</layout>
</frontend>
</config>
appdesignfrontendbasedefaultlayouttestmodule.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<testmodule_index_index>
<reference name="content">
<block type="testmodule/test" name="test" template="testmodule/test.phtml" />
</reference>
</testmodule_index_index>
</layout>`
appcodelocalSoumenTestmoduleBlockTest.php
class Soumen_Testmodule_Block_Test extends Mage_Core_Block_Template
public function getContent()
return "Hello World";
appdesignfrontendbasedefaulttemplatetestmoduletest.phtml
<?php echo $this->getContent();?>
Now when I call http://magento/testmodule... Then it displays the dufault page,
but should show Hello World . Can Someone help me out , that what wrong I am doing
magento-1.9 blocks
I have created a module with controller and model. But I am now trying to load a custom view where I can stuff all my PHP,css,js code into that PHTML file.
Here is my Block of Code
appcodelocalSoumenTestmodulecontrollersIndexController.php
IndexController file
public function indexAction()
echo "This is default";
public function sayHelloAction()
Mage::log('im in Controller');
$this->loadLayout();
$this->renderLayout();
Zend_Debug::dump($this->getLayout()->getUpdate()->getHandles());
Config file
appcodelocalSoumenTestmoduleetcconfig.xml
<config>
<frontend>
<routers>
<Soumen_Testmodule>
<use>standard</use>
<args>
<module>Soumen_Testmodule</module>
<frontName>testmodule</frontName>
</args>
</Soumen_Testmodule>
</routers>
<layout>
<updates>
<testmodule>
<file>testmodule.xml</file>
</testmodule>
</updates>
</layout>
</frontend>
</config>
appdesignfrontendbasedefaultlayouttestmodule.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<testmodule_index_index>
<reference name="content">
<block type="testmodule/test" name="test" template="testmodule/test.phtml" />
</reference>
</testmodule_index_index>
</layout>`
appcodelocalSoumenTestmoduleBlockTest.php
class Soumen_Testmodule_Block_Test extends Mage_Core_Block_Template
public function getContent()
return "Hello World";
appdesignfrontendbasedefaulttemplatetestmoduletest.phtml
<?php echo $this->getContent();?>
Now when I call http://magento/testmodule... Then it displays the dufault page,
but should show Hello World . Can Someone help me out , that what wrong I am doing
magento-1.9 blocks
magento-1.9 blocks
edited 2 days ago
Teja Bhagavan Kollepara
3,00841949
3,00841949
asked Jan 11 '17 at 16:22
Soumen Kumar SahaSoumen Kumar Saha
13
13
Is that the entire config.xml and controller file? What do you see in your browser? Do you have a layout file? Can you post it? As this question stands, there's nowhere near enough information to start on it...
– tjons
Jan 11 '17 at 16:26
add yourtestmodule.xmlfrom layout folder and block code
– sandip
Jan 11 '17 at 16:27
<?xml version="1.0"?> <layout version="0.1.0"> <testmodule_index_sayHello> <reference name="content"> <block name="testmodule" template="newpage/content.phtml"/> </reference> </testmodule_index_sayHello> </layout>
– Soumen Kumar Saha
Jan 11 '17 at 16:27
I am able to see the default page of my theme, but I want to display the contents of my conent.phtml file , where I have added my HTML stuff
– Soumen Kumar Saha
Jan 11 '17 at 16:31
@SoumenKumarSaha for creating module you need to follow some basic steps.....as i written bellow (by Vishal Thakur). Just edit module name (Excellence_Test) as you want.
– Vishal Thakur
Jan 11 '17 at 19:19
add a comment |
Is that the entire config.xml and controller file? What do you see in your browser? Do you have a layout file? Can you post it? As this question stands, there's nowhere near enough information to start on it...
– tjons
Jan 11 '17 at 16:26
add yourtestmodule.xmlfrom layout folder and block code
– sandip
Jan 11 '17 at 16:27
<?xml version="1.0"?> <layout version="0.1.0"> <testmodule_index_sayHello> <reference name="content"> <block name="testmodule" template="newpage/content.phtml"/> </reference> </testmodule_index_sayHello> </layout>
– Soumen Kumar Saha
Jan 11 '17 at 16:27
I am able to see the default page of my theme, but I want to display the contents of my conent.phtml file , where I have added my HTML stuff
– Soumen Kumar Saha
Jan 11 '17 at 16:31
@SoumenKumarSaha for creating module you need to follow some basic steps.....as i written bellow (by Vishal Thakur). Just edit module name (Excellence_Test) as you want.
– Vishal Thakur
Jan 11 '17 at 19:19
Is that the entire config.xml and controller file? What do you see in your browser? Do you have a layout file? Can you post it? As this question stands, there's nowhere near enough information to start on it...
– tjons
Jan 11 '17 at 16:26
Is that the entire config.xml and controller file? What do you see in your browser? Do you have a layout file? Can you post it? As this question stands, there's nowhere near enough information to start on it...
– tjons
Jan 11 '17 at 16:26
add your
testmodule.xml from layout folder and block code– sandip
Jan 11 '17 at 16:27
add your
testmodule.xml from layout folder and block code– sandip
Jan 11 '17 at 16:27
<?xml version="1.0"?> <layout version="0.1.0"> <testmodule_index_sayHello> <reference name="content"> <block name="testmodule" template="newpage/content.phtml"/> </reference> </testmodule_index_sayHello> </layout>
– Soumen Kumar Saha
Jan 11 '17 at 16:27
<?xml version="1.0"?> <layout version="0.1.0"> <testmodule_index_sayHello> <reference name="content"> <block name="testmodule" template="newpage/content.phtml"/> </reference> </testmodule_index_sayHello> </layout>
– Soumen Kumar Saha
Jan 11 '17 at 16:27
I am able to see the default page of my theme, but I want to display the contents of my conent.phtml file , where I have added my HTML stuff
– Soumen Kumar Saha
Jan 11 '17 at 16:31
I am able to see the default page of my theme, but I want to display the contents of my conent.phtml file , where I have added my HTML stuff
– Soumen Kumar Saha
Jan 11 '17 at 16:31
@SoumenKumarSaha for creating module you need to follow some basic steps.....as i written bellow (by Vishal Thakur). Just edit module name (Excellence_Test) as you want.
– Vishal Thakur
Jan 11 '17 at 19:19
@SoumenKumarSaha for creating module you need to follow some basic steps.....as i written bellow (by Vishal Thakur). Just edit module name (Excellence_Test) as you want.
– Vishal Thakur
Jan 11 '17 at 19:19
add a comment |
2 Answers
2
active
oldest
votes
In your testmodule.xml file use this
<testmodule_index_sayHello>
<reference name="content">
<block type="modulename/block" name="testmodule" template="newpage/content.phtml"/>
</reference>
</testmodule_index_sayHello>
If you don't have block of your module then you can use core/template as block type
add a comment |
There are few changes to make to the existing config.xml file. Since now we are using layouts, we will create our own layout file for our module. Lets name our module’s layout file as test.xml. We will place it in our theme/layout folder.
<?xml version="1.0"?>
<config>
<modules>
<Excellence_Test>
<version>0.1.0</version>
</Excellence_Test>
</modules>
<frontend>
<routers>
<test>
<use>standard</use>
<args>
<module>Excellence_Test</module>
<frontName>test</frontName>
</args>
</test>
</routers>
<layout> <!-- New Section Added -->
<updates>
<test>
<file>test.xml</file> <!-- This is name of the layout file for this module -->
</test>
</updates>
</layout>
</frontend>
<global>
<blocks>
<test>
<class>Excellence_Test_Block</class>
</test>
</blocks>
<helpers>
<test>
<class>Excellence_Test_Helper</class>
</test>
</helpers>
</global>
</config>
Now create the test.xml file in your theme layout folder. Like in my case its app/design/frontend/default/default/layout/test.xml or if you have create your own theme, put the layout file there. Here are the contents of the file.
<?xml version="1.0"?>
<layout version="0.1.0">
<test_index_index>
<reference name="content">
<block type="test/test" name="test" template="test/test.phtml" />
</reference>
</test_index_index>
</layout>
The explanation of this layout file is given previously here. So the block we used is “test/test” which equal class Excellence_Test_Block_Test and phtml file used is test/test.phtml
So we will create a phtml file in location app/design/frontend/default/default/templates/test/test.phtml
<?php
echo $this->getContent();
?>
In the file, we are calling a function getContent(); this function is to be declared in the block Test.php block file. As we have seen previous, the $this variable here is actually an object of our block class, which we define as ‘type’ in our layout.xml. Just to confirm you write below code in your phtml file.
<?php echo get_class($this); ?>
The output should be Excellence_Test_Block_Test.
Now create the file Test.php at location app/code/local/Excellence/Test/Block/Test.php
<?php
class Excellence_Test_Block_Test extends Mage_Core_Block_Template
public function getContent()
return "Hello World";
Now, to call all these layouts we need to make some changes in the IndexController.php
<?php
class Excellence_Test_IndexController extends Mage_Core_Controller_Front_Action
public function indexAction()
$this->loadLayout(); //This function read all layout files and loads them in memory
$this->renderLayout(); //This function processes and displays all layout phtml and php files.
Open the url www.your-magento.com/test/ again and it will again print ‘helloword’.
add a comment |
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f154293%2fmagento-unable-to-load-my-custom-layout-through-controller%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
In your testmodule.xml file use this
<testmodule_index_sayHello>
<reference name="content">
<block type="modulename/block" name="testmodule" template="newpage/content.phtml"/>
</reference>
</testmodule_index_sayHello>
If you don't have block of your module then you can use core/template as block type
add a comment |
In your testmodule.xml file use this
<testmodule_index_sayHello>
<reference name="content">
<block type="modulename/block" name="testmodule" template="newpage/content.phtml"/>
</reference>
</testmodule_index_sayHello>
If you don't have block of your module then you can use core/template as block type
add a comment |
In your testmodule.xml file use this
<testmodule_index_sayHello>
<reference name="content">
<block type="modulename/block" name="testmodule" template="newpage/content.phtml"/>
</reference>
</testmodule_index_sayHello>
If you don't have block of your module then you can use core/template as block type
In your testmodule.xml file use this
<testmodule_index_sayHello>
<reference name="content">
<block type="modulename/block" name="testmodule" template="newpage/content.phtml"/>
</reference>
</testmodule_index_sayHello>
If you don't have block of your module then you can use core/template as block type
answered Jan 11 '17 at 19:00
PiyushPiyush
4,82972054
4,82972054
add a comment |
add a comment |
There are few changes to make to the existing config.xml file. Since now we are using layouts, we will create our own layout file for our module. Lets name our module’s layout file as test.xml. We will place it in our theme/layout folder.
<?xml version="1.0"?>
<config>
<modules>
<Excellence_Test>
<version>0.1.0</version>
</Excellence_Test>
</modules>
<frontend>
<routers>
<test>
<use>standard</use>
<args>
<module>Excellence_Test</module>
<frontName>test</frontName>
</args>
</test>
</routers>
<layout> <!-- New Section Added -->
<updates>
<test>
<file>test.xml</file> <!-- This is name of the layout file for this module -->
</test>
</updates>
</layout>
</frontend>
<global>
<blocks>
<test>
<class>Excellence_Test_Block</class>
</test>
</blocks>
<helpers>
<test>
<class>Excellence_Test_Helper</class>
</test>
</helpers>
</global>
</config>
Now create the test.xml file in your theme layout folder. Like in my case its app/design/frontend/default/default/layout/test.xml or if you have create your own theme, put the layout file there. Here are the contents of the file.
<?xml version="1.0"?>
<layout version="0.1.0">
<test_index_index>
<reference name="content">
<block type="test/test" name="test" template="test/test.phtml" />
</reference>
</test_index_index>
</layout>
The explanation of this layout file is given previously here. So the block we used is “test/test” which equal class Excellence_Test_Block_Test and phtml file used is test/test.phtml
So we will create a phtml file in location app/design/frontend/default/default/templates/test/test.phtml
<?php
echo $this->getContent();
?>
In the file, we are calling a function getContent(); this function is to be declared in the block Test.php block file. As we have seen previous, the $this variable here is actually an object of our block class, which we define as ‘type’ in our layout.xml. Just to confirm you write below code in your phtml file.
<?php echo get_class($this); ?>
The output should be Excellence_Test_Block_Test.
Now create the file Test.php at location app/code/local/Excellence/Test/Block/Test.php
<?php
class Excellence_Test_Block_Test extends Mage_Core_Block_Template
public function getContent()
return "Hello World";
Now, to call all these layouts we need to make some changes in the IndexController.php
<?php
class Excellence_Test_IndexController extends Mage_Core_Controller_Front_Action
public function indexAction()
$this->loadLayout(); //This function read all layout files and loads them in memory
$this->renderLayout(); //This function processes and displays all layout phtml and php files.
Open the url www.your-magento.com/test/ again and it will again print ‘helloword’.
add a comment |
There are few changes to make to the existing config.xml file. Since now we are using layouts, we will create our own layout file for our module. Lets name our module’s layout file as test.xml. We will place it in our theme/layout folder.
<?xml version="1.0"?>
<config>
<modules>
<Excellence_Test>
<version>0.1.0</version>
</Excellence_Test>
</modules>
<frontend>
<routers>
<test>
<use>standard</use>
<args>
<module>Excellence_Test</module>
<frontName>test</frontName>
</args>
</test>
</routers>
<layout> <!-- New Section Added -->
<updates>
<test>
<file>test.xml</file> <!-- This is name of the layout file for this module -->
</test>
</updates>
</layout>
</frontend>
<global>
<blocks>
<test>
<class>Excellence_Test_Block</class>
</test>
</blocks>
<helpers>
<test>
<class>Excellence_Test_Helper</class>
</test>
</helpers>
</global>
</config>
Now create the test.xml file in your theme layout folder. Like in my case its app/design/frontend/default/default/layout/test.xml or if you have create your own theme, put the layout file there. Here are the contents of the file.
<?xml version="1.0"?>
<layout version="0.1.0">
<test_index_index>
<reference name="content">
<block type="test/test" name="test" template="test/test.phtml" />
</reference>
</test_index_index>
</layout>
The explanation of this layout file is given previously here. So the block we used is “test/test” which equal class Excellence_Test_Block_Test and phtml file used is test/test.phtml
So we will create a phtml file in location app/design/frontend/default/default/templates/test/test.phtml
<?php
echo $this->getContent();
?>
In the file, we are calling a function getContent(); this function is to be declared in the block Test.php block file. As we have seen previous, the $this variable here is actually an object of our block class, which we define as ‘type’ in our layout.xml. Just to confirm you write below code in your phtml file.
<?php echo get_class($this); ?>
The output should be Excellence_Test_Block_Test.
Now create the file Test.php at location app/code/local/Excellence/Test/Block/Test.php
<?php
class Excellence_Test_Block_Test extends Mage_Core_Block_Template
public function getContent()
return "Hello World";
Now, to call all these layouts we need to make some changes in the IndexController.php
<?php
class Excellence_Test_IndexController extends Mage_Core_Controller_Front_Action
public function indexAction()
$this->loadLayout(); //This function read all layout files and loads them in memory
$this->renderLayout(); //This function processes and displays all layout phtml and php files.
Open the url www.your-magento.com/test/ again and it will again print ‘helloword’.
add a comment |
There are few changes to make to the existing config.xml file. Since now we are using layouts, we will create our own layout file for our module. Lets name our module’s layout file as test.xml. We will place it in our theme/layout folder.
<?xml version="1.0"?>
<config>
<modules>
<Excellence_Test>
<version>0.1.0</version>
</Excellence_Test>
</modules>
<frontend>
<routers>
<test>
<use>standard</use>
<args>
<module>Excellence_Test</module>
<frontName>test</frontName>
</args>
</test>
</routers>
<layout> <!-- New Section Added -->
<updates>
<test>
<file>test.xml</file> <!-- This is name of the layout file for this module -->
</test>
</updates>
</layout>
</frontend>
<global>
<blocks>
<test>
<class>Excellence_Test_Block</class>
</test>
</blocks>
<helpers>
<test>
<class>Excellence_Test_Helper</class>
</test>
</helpers>
</global>
</config>
Now create the test.xml file in your theme layout folder. Like in my case its app/design/frontend/default/default/layout/test.xml or if you have create your own theme, put the layout file there. Here are the contents of the file.
<?xml version="1.0"?>
<layout version="0.1.0">
<test_index_index>
<reference name="content">
<block type="test/test" name="test" template="test/test.phtml" />
</reference>
</test_index_index>
</layout>
The explanation of this layout file is given previously here. So the block we used is “test/test” which equal class Excellence_Test_Block_Test and phtml file used is test/test.phtml
So we will create a phtml file in location app/design/frontend/default/default/templates/test/test.phtml
<?php
echo $this->getContent();
?>
In the file, we are calling a function getContent(); this function is to be declared in the block Test.php block file. As we have seen previous, the $this variable here is actually an object of our block class, which we define as ‘type’ in our layout.xml. Just to confirm you write below code in your phtml file.
<?php echo get_class($this); ?>
The output should be Excellence_Test_Block_Test.
Now create the file Test.php at location app/code/local/Excellence/Test/Block/Test.php
<?php
class Excellence_Test_Block_Test extends Mage_Core_Block_Template
public function getContent()
return "Hello World";
Now, to call all these layouts we need to make some changes in the IndexController.php
<?php
class Excellence_Test_IndexController extends Mage_Core_Controller_Front_Action
public function indexAction()
$this->loadLayout(); //This function read all layout files and loads them in memory
$this->renderLayout(); //This function processes and displays all layout phtml and php files.
Open the url www.your-magento.com/test/ again and it will again print ‘helloword’.
There are few changes to make to the existing config.xml file. Since now we are using layouts, we will create our own layout file for our module. Lets name our module’s layout file as test.xml. We will place it in our theme/layout folder.
<?xml version="1.0"?>
<config>
<modules>
<Excellence_Test>
<version>0.1.0</version>
</Excellence_Test>
</modules>
<frontend>
<routers>
<test>
<use>standard</use>
<args>
<module>Excellence_Test</module>
<frontName>test</frontName>
</args>
</test>
</routers>
<layout> <!-- New Section Added -->
<updates>
<test>
<file>test.xml</file> <!-- This is name of the layout file for this module -->
</test>
</updates>
</layout>
</frontend>
<global>
<blocks>
<test>
<class>Excellence_Test_Block</class>
</test>
</blocks>
<helpers>
<test>
<class>Excellence_Test_Helper</class>
</test>
</helpers>
</global>
</config>
Now create the test.xml file in your theme layout folder. Like in my case its app/design/frontend/default/default/layout/test.xml or if you have create your own theme, put the layout file there. Here are the contents of the file.
<?xml version="1.0"?>
<layout version="0.1.0">
<test_index_index>
<reference name="content">
<block type="test/test" name="test" template="test/test.phtml" />
</reference>
</test_index_index>
</layout>
The explanation of this layout file is given previously here. So the block we used is “test/test” which equal class Excellence_Test_Block_Test and phtml file used is test/test.phtml
So we will create a phtml file in location app/design/frontend/default/default/templates/test/test.phtml
<?php
echo $this->getContent();
?>
In the file, we are calling a function getContent(); this function is to be declared in the block Test.php block file. As we have seen previous, the $this variable here is actually an object of our block class, which we define as ‘type’ in our layout.xml. Just to confirm you write below code in your phtml file.
<?php echo get_class($this); ?>
The output should be Excellence_Test_Block_Test.
Now create the file Test.php at location app/code/local/Excellence/Test/Block/Test.php
<?php
class Excellence_Test_Block_Test extends Mage_Core_Block_Template
public function getContent()
return "Hello World";
Now, to call all these layouts we need to make some changes in the IndexController.php
<?php
class Excellence_Test_IndexController extends Mage_Core_Controller_Front_Action
public function indexAction()
$this->loadLayout(); //This function read all layout files and loads them in memory
$this->renderLayout(); //This function processes and displays all layout phtml and php files.
Open the url www.your-magento.com/test/ again and it will again print ‘helloword’.
edited Jan 11 '17 at 18:58
answered Jan 11 '17 at 18:42
Vishal ThakurVishal Thakur
429512
429512
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f154293%2fmagento-unable-to-load-my-custom-layout-through-controller%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown

Is that the entire config.xml and controller file? What do you see in your browser? Do you have a layout file? Can you post it? As this question stands, there's nowhere near enough information to start on it...
– tjons
Jan 11 '17 at 16:26
add your
testmodule.xmlfrom layout folder and block code– sandip
Jan 11 '17 at 16:27
<?xml version="1.0"?> <layout version="0.1.0"> <testmodule_index_sayHello> <reference name="content"> <block name="testmodule" template="newpage/content.phtml"/> </reference> </testmodule_index_sayHello> </layout>
– Soumen Kumar Saha
Jan 11 '17 at 16:27
I am able to see the default page of my theme, but I want to display the contents of my conent.phtml file , where I have added my HTML stuff
– Soumen Kumar Saha
Jan 11 '17 at 16:31
@SoumenKumarSaha for creating module you need to follow some basic steps.....as i written bellow (by Vishal Thakur). Just edit module name (Excellence_Test) as you want.
– Vishal Thakur
Jan 11 '17 at 19:19