<frontend> <routers> <!-- declare a router for urls starting with /sampleorder --> <sampleorder> <use>standard</use> <args> <module>Mage_Sampleorder</module> <frontName>sampleorder</frontName> </args> </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>
3. Create a controller:
app/code/local/Mage/Sampleorder/controllers/TsampleController.php:
<?php
class Mage_Sampleorder_TsampleController extends Mage_Core_Controller_Front_Action { public function indexAction() { $this->loadLayout(); $this->renderLayout(); } }
4. Create a custom functionality block (optional):
app/code/local/Mage/Sampleorder/Block/Tsample.php:
<?php
class Mage_Sampleorder_Block_Tsample extends Mage_Core_Block_Template { public function getSomeValue() { return 'this value is taken from custom block'; } }
5. Create a template that you would like to use on this page:
app/design/frontend/default/default/template/sampleorder/tsample.phtml:
<p><?=$this->__("Translated label for some value: %s", $this->getSomeValue())?></p>
6. Create a layout update file:
app/design/frontend/default/default/layout/sampleorder.xml:
<?xml version="1.0"?> <layout> <sampleorder_tsample_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>
Thanks a lot Moshe.
But now when i execute this url http://localhost:145/sampleorder/tsample, I am not able to see my HTML code executed.
Please help.
I request you to please give me your email id, so that i can chat and clear my doubts.
It shows me the template.In the Tsamplecontroller.php, under the indexAction, I have given echo “*******” and in my tsample.phtml, i have given “Hello world”. i can see only “*********”. I cant see Hello world printed. Please tell me.
Try adding the contents of <sampleorder_tsample_index> tag from step 6 into app/design/frontend/default/default/layout/main.xml, i forgot that this change wasn’t commited in last release, my bad.
Moshe,
Thank you very much. Thats a gr8 help from you. It worked finally. But the problem is I am getting the output twice.
Like this. Hello WorldHello World.
What can be the problem. How to resolve this?
Please tell me.
In step 6 i’ve provided 2 examples, for using custom block, or using generic template block:
<!-- 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> <!-- generic block until here -->
<!-- create tsample block --> <block type="sampleorder/tsample" name="sampleorder.tsample.custom" template="sampleorder/tsample.phtml"/> <!-- custom block until here -->
If you do not need any custom functionality in your template, leave only the first <block> tag, if you need to supply any custom calculations, use the 2nd one.
If you use generic ‘core/template’ block, you can skip step 4.
Moshe,
On ly local system, It works fine.
When i upload on the server, I dont see the HTML ouput.
In the admin panel, There is no cache management.
Please advice.
On the server, the application is running under the URL like http://mydomain.com/store/sampleorder/tsample.
Moshe,
When i create the same files on the server, I am not getting the HTML view.
http://mydomain.com/store/sampleorder/tsample.
In the admin panel, There is no cache management.
What do to?
Please advice.
Please help me. On on my local system, It works fine.
When i upload on the server, I dont see the HTML ouput.
In the admin panel, There is no cache management.
Please advice.
first step: /app/etc/local.xml looks not like it a module xml, but there is a subdirectory “modules” which looks correct.
Question: If I want to extend it now in my Own “Namespace” Can I create Myname_All.xml with all the modules in it or Do I have to edit the Mage_All.xml file?
first step: /app/etc/local.xml looks not like it a module xml, but there is a subdirectory “modules” which looks correct.
you are correct, the directory structure has changed to simple file drop-in declaration of custom modules.
Question: If I want to extend it now in my Own “Namespace” Can I create Myname_All.xml with all the modules in it or Do I have to edit the Mage_All.xml file?
you are correct again, each package should drop its own file with list of declared modules.