0
votes

I am trying to understand how what is happening in my config, when I set up a new module. To create a module called Ts_Wo I need to add

app/code/etc/modules/Ts_Wo.xml

<config>
   <modules>
      <Ts_Wo>
        <active>true</active>
        <codePool>local</codePool>
      </Ts_Wo>
   </modules>
</config>

And need to add

app/code/local/Ts/Wo/etc/config.xml

<config>
<modules>
    <Ts_Wo>
        <version>0.1.0</version>
    </Ts_Wo>
</modules>
<frontend>
    <routers>
        <wo>
            <use>standard</use>
            <args>
                <module>Ts_Wo</module>
                <frontName>wo</frontName>
            </args>
        </wo>
    </routers>
</frontend>
</config>

from here I go to the magento admin panel system->configuration->advanced to check if the module is enabled.

This has all worked fine until I spotted that I had created two modules Ts_Wo and Ts_Woo. Obviously I corrected the typo (which I found in modules node of config.xml) and I was back to one module

My questions:

1- I thought Magento required both of these files to create the module?

2- If it doesn't why do I create the two files?

2a- If it does how is it two different modules were displayed when I would have expected no module to be displayed?

1

1 Answers

2
votes
  1. "module" in Magento is a fuzzy, ill-defined concept. Depending on what the developer provides, the application/code will realize any classes and configuration which are part of the module in varying ways. For example, create a class Ts_Wo_Model_Foo at app/code/local/Ts/Wo/Model/Foo.php and then instantiate it in the application somewhere via new Ts_Wo_Model_Foo. It's a class which could be part of a module, yet the module itself doesn't properly exist in the application.

  2. There should be two separate configuration XML files so that the module's declaration XML (in app/etc/modules/, which is part of the overall configuration DOM) can be used to control whether the module's configuration XML (e.g. app/code/local/Ts/Wo/etc/config.xml) should be merged, and in what order (based on <depends>). Setting the <active> flag to false will prevent the module config from being merged.

    2a. The display in the admin (System > Configuration > Advanced) is notoriously deceiving. One, this group is used to disable module output. Two, the "modules" listed in this group are simply derived from all nodes under the modules configuration DOM xpath, nothing more, nothing less. Even "modules" with <active> flag set to false will appear in this list.