官术网_书友最值得收藏!

Basic extension configuration

With everything said, by now we should have a solid understanding of the Magento directory structure and be ready to grasp further concepts of the Magento internal structure.

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 <active>true</active> to <active>false</active>.

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 app/code/community/Foggyline/HappyHour/etc/config.xml file:

<?xml version="1.0"?>
<config>
   <modules>
      <Foggyline_HappyHour>
         <version>1.0.0.0</version>
      </Foggyline_HappyHour>
   </modules>
</config>
主站蜘蛛池模板: 获嘉县| 哈巴河县| 手机| 德惠市| 万全县| 安仁县| 塔河县| 乌审旗| 宜章县| 美姑县| 丹阳市| 那坡县| 高碑店市| 双流县| 聊城市| 红安县| 北海市| 龙里县| 祁连县| 定州市| 溧水县| 成武县| 巴南区| 旅游| 达日县| 澄城县| 梧州市| 平原县| 长兴县| 奉化市| 呼玛县| 镶黄旗| 临猗县| 泸定县| 长宁区| 黄浦区| 金平| 霞浦县| 廊坊市| 翁源县| 农安县|