I am new in magento i want to create a Hello World Module i am follow many tutorial but i am always getting 404 error
My app/etc/module file
<?xml version="1.0"?>
<config>
<modules>
<Quinchy_Demo>
<active>true</active>
<codePool>local</codePool>
</Quinchy_Demo>
</modules>
</config>
My Php clas file in app/local/Quinchy/Demo which is
<?php
class Quinchy_Demo_Model_Hotel extends Mage_Core_Controller_Front_Action{
public function indexAction()
{
echo "Hello Quinchy";
}
}
?>
and config file is
<?xml version="1.0"?>
<config>
<modules>
<Quinchy_Demo>
<version>0.1.0</version>
</Quinchy_Demo>
</modules>
<frontend>
<routers>
<quinchy>
<use>standard</use>
<args>
<module>Quinchy_Demo</module>
<frontName>quinchy</frontName>
</args>
</quinchy>
</routers>
</frontend>
</config>
and i calling this Module using this URL
127.0.0.1/magento/index.php/quinchy,
127.0.0.1/magento/quinchy/
127.0.0.1/magento/quinchy/index
File Structure enter image description here please help me
Your "model" should actually be a controller, which is the type of class that serves content to the frontend or adminhtml areas. Models are for dealing with data.
Try this for your controller:
# File: app/code/local/Quinchy/Demo/controllers/HotelController.php
<?php
class Quinchy_Demo_HotelController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
echo "Hello Quinchy";
exit;
}
}
BTW, you'd access this via /magento/quinchy/hotel/index
Your controller should be in the 'app/local/Quinchy/Demo/controllers/IndexController.php' file. And the class name should be 'Quinchy_Demo_IndexController' ( class Quinchy_Demo_IndexController extends Mage_Core_Controller_Front_Action
).
Your extension should look like this: app/etc/modules/Quinchy_Demo.xml
:
<?xml version="1.0"?>
<config>
<modules>
<Quinchy_Demo>
<active>true</active>
<codePool>local</codePool>
</Quinchy_Demo>
</modules>
</config>
app/code/local/Quinchy/Demo/etc/config.xml
:
<?xml version="1.0"?>
<config>
<modules>
<Quinchy_Demo>
<version>0.1.0</version>
</Quinchy_Demo>
</modules>
<frontend>
<routers>
<quinchy>
<use>standard</use>
<args>
<module>Quinchy_Demo</module>
<frontName>quinchy</frontName>
</args>
</quinchy>
</routers>
</frontend>
</config>
app/code/local/Quinchy/Demo/controllers/IndexController.php
:
<?php
class Quinchy_Demo_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
echo "Hello Quinchy";
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.