1

I am learning Magento. Somewhere in module I have seen below code in config.xml

<global>
    <rewrite>
            <namespace_modulename>
                <from><![CDATA[#^/module/controller/action/#]]></from>
                <to>/modulename/newcontroller/newaction/</to>
            </namespace_module>
        </rewrite>
        <rewrite>
            <namespace_modulename2>
                <from><![CDATA[#^/module/controller/action/#]]></from>
                <to>/modulename/newcontroller/newaction/</to>
            </namespace_modulename2>
        </rewrite>
        <rewrite>
            <namespace_modulename3>
                <from><![CDATA[#^/module/controller/action/#]]></from>
                <to>/modulename/newcontroller/newaction/</to>
            </namespace_module3>
        </rewrite>



    <blocks>
            <review>
                <rewrite>
                    <form>Namespace_Modulename_Block_Review_Form</form>
                </rewrite>
            </review>
        </blocks>
</global>

I have two question regarding this code.

  1. <namespace_modulename> it seems okay, But why they have used <namespace_modulename2>, <namespace_modulename3>. I mean why they have added number along with modulename.

  2. My second question is that in the <block> section, it seems here it is overwriting any predefined block. But how magento find which block have to rewrite.

johnwright121
  • 79
  • 2
  • 9

1 Answers1

0

Please review my answers, i hope this will help you out.

Answer 1:The reason for written numeric value with modulename: other two modules exist in same namespace directory and all are overwrite same controller action.

Answer 2 : Whenever magento application instantiate control read the config.xml file. If control found any rewrite node then it will look into upper level node. Let say control found node then control know user written to code for rewriting block class and inside rewrite node precedence/child class.

In your question, you want to rewrite the Mage_Review_Block_Form block and your custom class is Namespace/Modulename/Block/Review/Form.php

Thanks.

Abhishek Gupta
  • 1,185
  • 8
  • 17
  • thanks for reply, there is only one modulename in namespace directory, there is no any modulename2 and modulename3 in the same namespace directory. Thats why I am confused with this code – johnwright121 Dec 18 '14 at 06:34