What better way to explain things than an example; so let's start off by creating the simplest extension, which we will then extend bit by bit as we explain the Magento way of doing the object-oriented Model-View-Controller (MVC) architecture. If you are hearing of MVC for the first time, please take some time to familiarize yourself with the concept. You can find good starting material about it at http://en.wikipedia.org/wiki/Model–view–controller.
Previously, we gave examples on the extension name
Foggyline_HappyHour, so let's start with that.
In Magento, everything starts with a configuration file; after all, Magento is what we call the configuration-based MVC system. In a configuration-based system, in addition to adding the new files and classes, you often need to explicitly tell the system about them.
The first file we will create is
app/etc/modules/Foggyline_HappyHour.xml with the following content:
<?xml version="1.0"?> <config> <modules> <Foggyline_HappyHour> <active>true</active> <codePool>community</codePool> </Foggyline_HappyHour> </modules> </config>
With this file in place, Magento already becomes aware of your extension. You can confirm that by going under the Magento administration under System | Configuration | Advanced | Advanced | Disable Modules Output. Once you're there, you should see your
Foggyline_HappyHour extension on the list. It is important to know that setting the Disable Modules Output value to Disabled and saving the configuration has absolutely no impact on your extension being truly enabled or disabled.
Disabling the extension output is not the same as disabling the extension itself. Disabling the output of the extension via this configuration option has an effect only on your extension block classes that represent the visually output part of your extension. To truly disable the extension, one must edit the
app/etc/modules/Foggyline_HappyHour.xml file and change
Now that Magento sees our extension, we move on to the next step: creating the
app/code/community/Foggyline/HappyHour/etc/config.xml file. This
config.xml file is what is usually referred to as the extension configuration file by developers. The following code is the basic definition of our
<?xml version="1.0"?> <config> <modules> <Foggyline_HappyHour> <version>18.104.22.168</version> </Foggyline_HappyHour> </modules> </config>