class Mage_Sampleorder_IndexController extends Mage_Core_Controller_Front_Action { public function indexAction() { $this->loadLayout(); $this->renderLayout(); } }
I created a block in layout.xml :
<sampleorder_index> <!-- insert tsample blocks into middle column (content) --> <reference name="content"> <!-- create generic template block --> <block type="core/template" name="sampleorder.tsample.generic" template="sampleorder/tsample.phtml"> <action method="setSomeValue"><value>this value is assigned from layout</value></action> </block>
But apparently, the layout file in not taken into account. I have an empty page without any message. If I add echo"hello world” in IndexController, it is properly displayed, so the problem comes from the layout file.
Is there something special we should add to display an index page in the layout file ?
in app/code/local/MyNameSpace/Sampleorder/etc/config.xml
<?xml version="1.0"?> <config> <global> <blocks> <!-- declare sampleorder block group --> <sampleorder> <class>MyNameSpace_Sampleorder_Block</class> </sampleorder> </blocks> </global> <frontend> <routers> <!-- declare a router for urls starting with /sampleorder --> <mynamespace_sampleorder> <use>standard</use> <args> <module>MyNameSpace_Sampleorder</module> <frontName>sampleorder</frontName> </args> </mynamespace_sampleorder> </routers>
<layout> <updates> <!-- declare a file that will supply layout updates for your controllers --> <sampleorder> <file>sampleorder.xml</file> </sampleorder> </updates> </layout> </frontend> </config>
The file app/code/local/MyNameSpace/Sampleorder/controllers/TsampleController.php,
<?php
class MyNameSpace_Sampleorder_TsampleController extends Mage_Core_Controller_Front_Action { public function indexAction() { $this->loadLayout(); $this->renderLayout(); } }
/Block/Tsample.php
<?php
class MyNameSpace_Sampleorder_Block_Tsample extends Mage_Core_Block_Template { public function getSomeValue() { return 'this value is taken from custom block'; } }
and app/design/frontend/default/default/layout/sampleorder.xml
p><?=$this->__("Translated label for some value: %s", $this->getSomeValue())?></p>
Also, I added the xml to Add this to app/etc/modules/Mage_All.xml....but I still see page not found error.
There was no Mage folder in /app/code/local so I created one and entered all the files there and made the change from “MyNameSpace” to “Mage” to reflect that.
Just out of curiosity how can I even start to debug this.....I am not sure in one or all the xml files i created for my module are being read at all.
Any idea?
This won’t help your error - but for your info - you shouldn’t add to Mage_All.xml, but rather you should create Mage_Sampleorder.xml and put the xml in there - this way you don’t have to worry about core updates.
I followed the 6 steps Moshe gave, and followed the updates that followed in this thread.
I couldn’t get it to work, decided to leave this for now and get on with other stuff, so I deleted all the files I created ( I’m quite sure I didn’t change any existing files ), and now both frontend and backend turn blank / white with no output at all....
It worked fine just before… any ideas what causes this or even better, how to solve it? ( chache is off btw )
Yes I did. double checked just now.
And a global search for ‘sampleorder’ gives no results.
EDIT: never mind, my own fault. By editing local.xml as described earlier this thread I accidentally uploaded and old version of local.xml with old database settings. I learned: No database connection = everthing goes blank.