开发者

Zend Framework menu.xml in module throws exception

开发者 https://www.devze.com 2023-02-20 07:36 出处:网络
Usually I have a navigation file menu.xml in configs folder for Zend_Navigation. Now when I put it in modules/module-name/configs/ I get the error:

Usually I have a navigation file menu.xml in configs folder for Zend_Navigation.

Now when I put it in modules/module-name/configs/ I get the error:

Section 'production' cannot be found in /blah/blah/blah/menu.xml.

I understand [production] is the section for config ini files, do I need it in xml as well? Am I missing something really obvious? How could 开发者_运维技巧I have navigation xml files in the module directory (to keep modules independent)?


OK this is what I had to do to make it work. Everything based just on trial/error, I don't know underlying mechanisms why it had to be this way and not the "normal" way (like it works without modules).

The file must have a production node, and it must be used for config for Zend_Navigation in module's Bootstrap.php:

$config = new Zend_Config_Xml( APPLICATION_PATH . '/modules/default/configs/navigation.xml', 'production' );
$container = new Zend_Navigation( $config );

XML file:

<?xml version="1.0" encoding="UTF-8"?>
<configdata>
    <production>        
            <page1>
                <label>My page 1</label>
                <controller>page</controller>
                <action>index</action>
            </page1>
<!-- more pages here -->
    </production>
</configdata>

I have no idea why it has to be that way (or is it possible to have it any other way) so I'd appreciate if you tell it in comments, if you know it ;)

0

精彩评论

暂无评论...
验证码 换一张
取 消