Magento 的 config.xml 配置参数详解

Path: app/code/(codepool)/(NameSpace)/(ModuleName)/etc/config.xml
当你在Magento中新增一个或更新一个module的时候,需要在此config.xml中对所有的models,blocks,classes等做相应的配置。每一个module都有一个单独的config.xml文件,但是Magento在加载解析这些config.xml文件的时候整合在一起分析的。 所以每个config.xml文件都需要有<(ModuleName)> 来区别于其他的模块,如果一个模块下的config.xml文件中没有定义<(ModuleName)> ,该文件中其他的定义将被其他的文件覆盖掉。由此,严格按照Magento要求的书写方式来对相应的Module做配置是非常重要的(例如, <(modulename)_setup>)。
XML Structure


   
        <(NameSpace_ModuleName)>
   

   
       
       
       
       
       
       
       
       
        <(modulename)>
   

   
       
       
       
   

   
       
       
       
       
        <(modulename)>
   

   
       
   

   
       
       
       
       
   

   
        <(modulename)>
   

   
       
   

   
       
   


注意,上面只是一个config.xml配置文件大致的框架,下面将对每一部分进行细致分析.
Elements

Element Description Example
1. modules 最基本的定义一个模块的名字,版本和是否依赖于其他模块 。
2. global 由于global的特性,你可以在其他地方定义一个模块,只要global下的正确定义该模块就行。
3. admin adminhtml 对system->configuration下的具体的项进行ACL定义 。
4. install Page。
5. frontend 主要定义router。
6. default
7. stores Adminhtml
8. websites Adminhtml

每个config.xml可大致分为上面表格中的小模块,下面就每一块进行细分

modules:


XML Structure
   
         <(NameSpace_ModuleName)>
             [true|false]
             [core|community|local]
            
                 <(AnotherNameSpace_ModuleName) />
            

             (version_number)
        
   

Elements
Element Description
1. active 该模块是否生效(该element的值可在后台修改)
2. codePool app/code 的具体路径
3. depends 是否依赖于其他的模块,如果被依赖的模块不存在,它就不active
4. version 定义版本,用于更新和安装

通常 active, codePool and depends 一般在 app/etc/modules/(NameSpace)_*.xml 文件中定义,而 version 在相应module下的config.xml 文件中定义.

global


XML Structure
   
       
            <(modulename)>
                (ClassName_Prefix)
                (modulename)_(resource_model_type)
                <(modulename)_(resource_model_type)>
                   
               
               
           
       

       
            <(modulename)_setup>
            <(modulename)_read>
            <(modulename)_write>
       

       
            <(modulename)>
                (ClassName_Prefix)
           
       

       
            <(modulename)>
                (ClassName_Prefix)
           
       

       
            <(page_handle?)>
                <(field_name)>?
           
       

       
       
            <(event_name)>
               
           
       

       
        <(modulename)>
   

Elements
Element Description
1. models
2. resources
3. blocks
4. helpers
5. fieldsets
6. template
7. events
8. eav_attributes
9. (modulename) 自定义的变量(如设置邮件或newletter时非常有用)


admin


XML Structure
   
       
            <(attribute_name) />
       
       
       
            <(modulename)>
                [standard|admin|default]
               
                    (NameSpace_ModuleName)
                    (frontname)
               

           
           
            <(modulename)>
               
                   
                        <(NameSpace_ModuleName)
                            before="(AnotherNameSpace_ModuleName)"
                            >
                            (New_ClassName)
                        <(NameSpace_ModuleName)
               

           
       

   

Elements
Element Description
1. attributes
2. fieldsets
3. routers

adminhtml

XML Structure
   
       
            <(event_name)>
               
           
       

       
           
                (modulename)/search_catalog
                catalog
           

           
                adminhtml/search_customer
                customer
           

           
                adminhtml/search_order
                sales
           

       

       
           
                <(NameSpace_ModuleName)>
                   
                        (name_of_translation_file.csv)
                   

               
           

       

       
           
                <(modulename)>
                    (name_of_layout_file.xml)
               
           

       

        <(modulename)>
   

Elements
Element Description
1. events
2. global_search
3. translate
4. layout
5. (modulename) 自定义变量


install


XML Structure
frontend
XML Structure
   
       
            <(page_handle)>/relative/url
       

       
            <(event_name)>
               
           
       

       
            <(modulename)>
                [standard|admin|default]
               
                    (NameSpace_ModuleName)
                    (frontname)
               

           
       

       
           
                <(NameSpace_ModuleName)>
                   
                        (name_of_translation_file.csv)
                   

               
           

       

       
           
                <(modulename)>
                    (name_of_layout_file.xml)                
           

       

   

Elements
Element Description
1. secure_url
2. events
3. routers
4. translate
5. layout


default
XML Structure
stores
XML Structure
websites
XML Structure

你可能感兴趣的:(Magento)