Magento Forum

   
Modules’ namespace
 
kohril
Member
 
Total Posts:  44
Joined:  2007-12-23
Lille, northernFrance
 

I’d like to use my own namespace but I didn’t manage to do it. I think it’s a little thing missing but I don’t know what ...

1) I made a directory for my namespace app/code/local/MyNamespace

2) I added an xml file in app/etc/modules named mynamespace_mymodule.xml :

<?xml version="1.0"?>
<config>
    <
modules>
        <
MyNamespace_MyModule>
            <
active>true</active>
            <
codePool>core</codePool>
        </
MyNamespace_MyModule>
    </
modules>
</
config>

3) I added a module in my Namespace’s folder :  app/code/local/MyNamespace/MyModule

4) I made an helper in app/code/local/MyNamespace/MyModule/Helper/Data.php :

<?php
class MyNamespace_MyModule_Helper_Data extends Mage_Core_Helper_Abstract
{

}

5) I wrote my config.xml that only adds an entry in admin menu (app/code/local/MyNamespace/MyModule/etc/config.xml) :

<?xml version="1.0"?>
<config>
    <
modules>
        <
MyNamespace_MyModule>
            <
version>1.0</version>
            <!-- 
Notre module a besoin du module adminhtml -->
            <
depends>
                <
Mage_Adminhtml />
            </
depends>
        </
MyNamespace_MyModule>
    </
modules>
 
    <
adminhtml>
        <
menu>
            <
mymodule translate="title" module="mymodule">
                <
title>My Module in my namespace</title>
                <
sort_order>30</sort_order>
            </
mymodule>
        </
menu>

        <
acl>
            <
resources>
                <
admin>
                    <
children>
                        <
mymodule>
                            <
title>My Module</title>
                            <
sort_order>30</sort_order>
                        </
mymodule>
                    </
children>
                </
admin>
            </
resources>
        </
acl>
    </
adminhtml>
</
config>

Is there anything else I should do ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
kohril
Member
 
Total Posts:  44
Joined:  2007-12-23
Lille, northernFrance
 

Nobody can help ? :-(

 
Magento Community Magento Community
Magento Community
Magento Community
 
SeL_
Magento Team
 
Avatar
Total Posts:  1140
Joined:  2007-10-10
Paris, France
 

Hi,

You should try with

<codePool>local</codePool>
in mynamespace_mymodule.xml

 
Magento Community Magento Community
Magento Community
Magento Community
 
kohril
Member
 
Total Posts:  44
Joined:  2007-12-23
Lille, northernFrance
 

omg I did not see this error thx wink

But it still does not work, I have an error my Namespace seems not to be taken into account because the application looks for files in Mage/ folder :

Warning: include(Mage\Mymodule\Helper\Data.php[function.include]failed to open streamNo such file or directory in C:\Program Files\xampplite\htdocs\magento\app\code\core\Mage\Core\functions.php on line 44
[0] in __autoload
() in C:\Program Files\xampplite\htdocs\magento\app\code\core\Mage\Core\functions.php on line 44
[1] in __autoload
("Mage_Mymodule_Helper_Data"in C:\Program Files\xampplite\htdocs\magento\app\code\core\Mage\Core\Model\App.php on line 375
[2] in Mage_Core_Model_App
->getHelper("mymodule"in C:\Program Files\xampplite\htdocs\magento\app\Mage.php on line 325
[3] in Mage
::helper("mymodule"in C:\Program Files\xampplite\htdocs\magento\app\code\core\Mage\Adminhtml\Block\Page\Menu.php on line 66
[4] in Mage_Adminhtml_Block_Page_Menu
->_getHelperValue(Mage_Core_Model_Config_Elementin C:\Program Files\xampplite\htdocs\magento\app\code\core\Mage\Adminhtml\Block\Page\Menu.php on line 91
[5] in Mage_Adminhtml_Block_Page_Menu
->_buildMenuArray() in C:\Program Files\xampplite\htdocs\magento\app\code\core\Mage\Adminhtml\Block\Page\Menu.php on line 51
[6] in Mage_Adminhtml_Block_Page_Menu
->getMenuArray() in C:\Program Files\xampplite\htdocs\magento\app\design\adminhtml\default\default\template\page\menu.phtml on line 26
[7] in 
include("C:\Program Files\xampplite\htdocs\magento\app\design\adminhtml\default\default\template\page\menu.ph"in C:\Program Files\xampplite\htdocs\magento\app\code\core\Mage\Core\Block\Template.php on line 112
[8] in Mage_Core_Block_Template
->fetchView("adminhtml\default\default\template\page/menu.phtml"in C:\Program Files\xampplite\htdocs\magento\app\code\core\Mage\Core\Block\Template.php on line 144
[9] in Mage_Core_Block_Template
->renderView() in C:\Program Files\xampplite\htdocs\magento\app\code\core\Mage\Core\Block\Template.php on line 183
[10] in Mage_Core_Block_Template
->_toHtml() in C:\Program Files\xampplite\htdocs\magento\app\code\core\Mage\Core\Block\Abstract.php on line 549
[11] in Mage_Core_Block_Abstract
->toHtml() in C:\Program Files\xampplite\htdocs\magento\app\code\core\Mage\Core\Block\Abstract.php on line 435
[12] in Mage_Core_Block_Abstract
->_getChildHtml("menu"1in C:\Program Files\xampplite\htdocs\magento\app\code\core\Mage\Core\Block\Abstract.php on line 412
[13] in Mage_Core_Block_Abstract
->getChildHtml("menu"in C:\Program Files\xampplite\htdocs\magento\app\design\adminhtml\default\default\template\page.phtml on line 108
[14] in 
include("C:\Program Files\xampplite\htdocs\magento\app\design\adminhtml\default\default\template\page.phtml"in C:\Program Files\xampplite\htdocs\magento\app\code\core\Mage\Core\Block\Template.php on line 112
[15] in Mage_Core_Block_Template
->fetchView("adminhtml\default\default\template\page.phtml"in C:\Program Files\xampplite\htdocs\magento\app\code\core\Mage\Core\Block\Template.php on line 144
[16] in Mage_Core_Block_Template
->renderView() in C:\Program Files\xampplite\htdocs\magento\app\code\core\Mage\Core\Block\Template.php on line 183
[17] in Mage_Core_Block_Template
->_toHtml() in C:\Program Files\xampplite\htdocs\magento\app\code\core\Mage\Core\Block\Abstract.php on line 549
[18] in Mage_Core_Block_Abstract
->toHtml() in C:\Program Files\xampplite\htdocs\magento\app\code\core\Mage\Core\Model\Layout.php on line 437
[19] in Mage_Core_Model_Layout
->getOutput() in C:\Program Files\xampplite\htdocs\magento\app\code\core\Mage\Core\Controller\Varien\Action.php on line 314
[20] in Mage_Core_Controller_Varien_Action
->renderLayout() in C:\Program Files\xampplite\htdocs\magento\app\code\core\Mage\Adminhtml\Controller\Action.php on line 144
[21] in Mage_Adminhtml_Controller_Action
->norouteAction() in C:\Program Files\xampplite\htdocs\magento\app\code\core\Mage\Core\Controller\Varien\Action.php on line 337
[22] in Mage_Core_Controller_Varien_Action
->dispatch("noroute"in C:\Program Files\xampplite\htdocs\magento\app\code\core\Mage\Core\Controller\Varien\Router\Admin.php on line 141
[23] in Mage_Core_Controller_Varien_Router_Admin
->match(Mage_Core_Controller_Request_Httpin C:\Program Files\xampplite\htdocs\magento\app\code\core\Mage\Core\Controller\Varien\Front.php on line 147
[24] in Mage_Core_Controller_Varien_Front
->dispatch() in C:\Program Files\xampplite\htdocs\magento\app\Mage.php on line 388
[25] in Mage
::run("base"in C:\Program Files\xampplite\htdocs\magento\index.php on line 28

I wonder if there is a config.xml parameter that says where are the file located. But I have not found anything like that ...

Edit : I also tried adding this in config.xml but it still does not work :

<global>
    <
models>
        <class>
MyNamespace_MyModule_Model</class>
    </
models>
    <
helpers>
        <class>
MyNamespace_MyModule_Helper</class>
    </
helpers>
</global>

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mark_Kimsal
Sr. Member
 
Total Posts:  186
Joined:  2007-09-12
Michigan, USA
 

<global>
   <
mymodule>
       <
helpers>
             <class>
MyNs_MyModule_Helper</class>
       </
helpers>
   </
mymodule>
</global>

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

<config>
    <global>
        <
helpers>
            <
mymodule>
                <class>
MyNs_MyModule_Helper</class>
            </
mymodule>
        </
helpers>
    </global>
</
config>

same for models

 
Magento Community Magento Community
Magento Community
Magento Community
 
kohril
Member
 
Total Posts:  44
Joined:  2007-12-23
Lille, northernFrance
 

Thank you very much ! It works fine now (using Moshe’s code).

For next people who would like to create their own namespace : take care to write <mymodule> (in <helpers> or <models>) with lowercase otherwise it seems not to be working !

Anthony

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top