Zend Framework 1中的下拉菜单

时间:2012-11-09 09:26:58

标签: zend-framework drop-down-menu navigation

我想在使用ZF 1.X

的网站构建中实现下拉菜单

在我的应用程序/ layouts / layout.phtml中,我接到了电话

$this->navigation()->menu()->renderMenu(   
    $this->navigation()->findByLabel('My Account'),
    array('maxDepth' => 0)
);

在myapp / Controller / Plugin / Navigation.php中,我看到标有“我的帐户”的菜单:

$account_container = new Zend_Navigation_Page_Mvc(
            array(
                  'route' => 'account_index',
                  'label' => 'My Account',
                  'pages' => array(
                        new Zend_Navigation_Page_Mvc(
                            array(
                            'route' => 'productions_list',
                            'label' => 'My Productions',
                            )
                        ),
                        new Zend_Navigation_Page_Mvc(
                            array(
                                'route' => 'productions_create',
                                'label' => 'Create a Production',
                            )
                        ),
                        new Zend_Navigation_Page_Mvc(
                            array(
                                'route' => 'account_inbox',
                                'label' => sprintf('My Inbox (%s)', $ident->getAllUnreadMessagesCount()),
                                'id' => 'inbox-count'
                            )
                        ),
                        new Zend_Navigation_Page_Mvc(
                            array(
                                 'route' => 'search_search_productions',
                                 'label' => 'Search Productions'
                            )
                        ),
                        new Zend_Navigation_Page_Mvc(
                            array(
                                 'route' => 'search_search_users',
                                 'label' => 'Search Users'
                            )
                        ),
                  )
            )
        );                 

并生成

<ul class="navigation"> 
    <li class="active"><a href="/news">Blog</a></li>
    ...
    ...
</ul>

我需要使用UL添加嵌套级别,如下所示:

<ul class="navigation"> 
    <li class="active">
        <a href="/news">Blog</a>
        <ul>
            <li><a href="/somethingelse">link</a></li>
            ...
            ...
        </ul>
    </li>
    ...
    ...
</ul>

这样做的方法是什么?我需要这个来生成javascript中的下拉菜单

2 个答案:

答案 0 :(得分:0)

我找到了解决方案, 'maxDepth'=&gt; 1还不够,

需要它在子数组中实现新页面:

$account_container = new Zend_Navigation_Page_Mvc(
        array(
              'route' => 'account_index',
              'label' => 'My Account',
              'pages' => array(
                    new Zend_Navigation_Page_Mvc(
                        array(
                        'route' => 'productions_list',
                        'label' => 'My Productions',
                        'pages' => array(
                            new Zend_Navigation_Page_Mvc(
                            array(
                                'route' => 'mychildurl',
                                'label' => 'My Child Label',
                            )
                        ),
                        )
                    ),

答案 1 :(得分:-1)

我想你只需要设置:

'maxDepth' => 1

而不是0。