tags:

views:

234

answers:

3

Can some professional experienced Magento developer tell me how to accomplish the following in Magento?

I want to know what are the possible tags that can fit in the "global" tag of the "config.xml" page of every module's etc folder?

I have tried searching for this answer at many places in Internet but in vain.

Please provide the full details along with it for Magento version >= 1.4.0.0, because I want at least the users accessing this website find it useful enough, instead of scratching their heads.

I really want a detailed explanation, because every newbie like me gets totally confused at this point. From what I know till now, is that in this page, you can set routers, rewrites, cron jobs, admin html, front-end html and many more. But without any strong concepts, none can go ahead with the belief that his code is 100% correct w.r.t. the Magento MVC architecture.

So please I want that strong fundamental concept, getting underlined here, with a detailed explanation about it, so that no one gets into this pitfall ever again.

I can understand one thing - for many it looks that a complete reference of valid global tags of Magento would be a misnomer, but I would like to clarify that there must be a set of those valid limited number of tags that goes under the global tag.

For example, I cannot just write a "stack" or "overflow" or "joseph" tag, which I'm quite sure that it will not be taken by Magento as a valid one. It is because the valid tags (like "models", "resources", "resource" & so on) are defined somewhere in Magento configuration, that they work.

This is my point actually, which I want to emphasize.

Many many thanks to those who can answer only upon knowing the total concept clearly.

+3  A: 

The fast answer is that there is no complete list of those tags. Magento doesn't use a strict grammar for XML files because they can be extended without any trouble. Looking at the 1.4 codebase, I performed the following command from a terminal:

cd /path/to/magento
grep -r global/ . 2>/dev/null | grep -v pearlib | grep php | sort

And got back about 75 lines where the global config path is invoked specifically. Some of these are simple:

global/page/layouts
global/pdf/totals
global/template/email
global/payment/cc/types

And others are far more obscure:

global/catalog/product/type/configurable/allow_product_types
global/helpers/core/encryption_model
global/widget/related_cache_types

On top of that, there are several which are invoked dynamically, such as your mentioned routers, rewrites, etc:

global/models/'.$model.'/resourceMode
global/'.$groupType.'s

In fact, I even found 4 references in my own extension code that added to the global space. Knowing all that, a complete reference of valid global tags would be a misnomer, and will likely change even during minor updates. To your last point, you cannot go forward with complete assurance that you will be in compliance w/ Magento's configuration model. Do your best to use the objects that are provided with the library, use samples from the rest of the app when possible, and forge ahead bravely when no help is given. :)

Hope that helps!

Thanks, Joe

Joseph Mastey
Knowledge Craving
Edited to include commands you'll probably have, though you'll need to be on Linux to perform them. If not, use whichever IDE you're familiar with and search for the string "global/".
Joseph Mastey
Knowledge Craving
+1  A: 

As Joseph said, there is no definite list of possibilities. My suggestion to you is to just start going through Magento's config.xml files. Just open up /app/code/core/Mage/ and then each folder inside there is a core module. So, Sales for instance. Open up Sales/etc/config.xml and see what they've done.

You can learn a ton just by looking at what Magento has already built. When I stopped trying to ask everyone questions and started inspecting and learning from the code that is already there, that's when I really started to progress in my understanding how everything works.

Prattski
+2  A: 

In fact, an important thing to keep in mind when developping for Magento, is that all the config.xml files are concatenated to give an output of one unique XML file which contains all nodes taken in all config.xml files of all modules.

The fact is, as Joseph said, that Magento does not use any strict grammar. We could say that the grammar is created by developpers themselves.

For example, if in your module, your config.xml defines :

<config>
   <mynode>
     <myconfigvar>Foo</myconfigvar>
   <mynode>
</config>

Any other module which defines the same node (<mynode></mynode>) can add a subnode and to this node, and your module will also be able to access this new node.

The better to understand what are the nodes used for, is to read the Core code. A good way to start understanding the way config.xml are parsed by magento is reading app/code/Core/Mage/Core/Config.php.

Understanding the way the function Mage::getStoreConfig() works, is a good way too.

Hugues.

Hugues ALARY
Important point highlighted, thanks. But still why will "mynode" tag be interpreted by Magento? There must be some sort of parser determining what set of tags will be properly interpreted by the Magento core code.
Knowledge Craving
The "mynode" tag is not interpreted by magento.It is just present. And you can access to it with this function : Mage::getConfig()->getNode('mynode/myconfigvar');If you want to access from your module to the node :<global> <fieldsets> <customer_account> <prefix><create>1</create><update>1</update><name>1</name></prefix></fieldsets></global>defined in config.xml of Customer module just type :Mage::getConfig()->getNode('global/fieldsets/customer_account');
Hugues ALARY
whoops.. sorry, I'm new to StackOverflow, didn't know that paragraphs' not respected in comments.
Hugues ALARY