【问题标题】:Dropdown Menu in Zend Framework 1Zend Framework 1 中的下拉菜单
【发布时间】:2012-11-09 09:26:57
【问题描述】:

我想在使用 ZF 1.X 的网站构建中实现下拉菜单

在我的 application/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中生成一个下拉菜单

【问题讨论】:

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


    【解决方案1】:

    我找到了解决方案, 'maxDepth' => 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',
                                )
                            ),
                            )
                        ),
    

    【讨论】:

      【解决方案2】:

      我猜你只需要设置:

      'maxDepth' =&gt; 1

      而不是 0。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-29
        • 2012-07-05
        • 1970-01-01
        • 2015-03-15
        • 2018-01-27
        相关资源
        最近更新 更多