1

我使用过 ZF2 的 Skeleton 应用程序进行学习。现在,我正在学习导航。我有一个问题。

  1. 在 service_manager 中添加了导航类。

    'Navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory'
    

    (模块的配置文件:module.config.php)

  2. 在 nav_config.php 中有以下代码。(配置/nav_config.php)

    <?php
    return array(
      'navigation' => array(
        'default' => array(
            'disc' => array(
                'label' => 'Album',
                'route' => 'album',
                'pages' => array(
                    'index' => array(
                        'label' => 'Listing',
                        //'route' => 'album/index',
                        'module' => 'album',
                        'controller' => 'album',
                        'action' => 'index',
                    ),
                    'add' => array(
                        'label' => 'Add Album',
                        //'route' => 'album/add',
                        'module' => 'album',
                        'controller' => 'album',
                        'action' => 'add',
                    ),
                ),
            ),
        ),
      ),
    );
    
  3. 在 layout.php 中,放置了这段代码。

    <?php
    echo $this->navigation()->breadcrumbs('navigation')->setMinDepth(0)->setLinkLast(true)->render();
    ?>
    

访问主机名/光盘时,我在面包屑中看到“专辑”文本。当我访问主机名/光盘/添加时,我再次得到相同的结果,那就是单独的“专辑”。但我想获得“专辑/添加专辑”。请指导实现。

4

1 回答 1

0

更新您的“光盘”节点以包含控制器和操作,它应该可以工作:

<?php
return array(
  'navigation' => array(
    'default' => array(
        'disc' => array(
            'label' => 'Album',
            'route' => 'album',
            'controller' => 'album', // add this
            'action' => 'index',     // add this
            'pages' => array(
                'index' => array(
                    'label' => 'Listing',
                    //'route' => 'album/index',
                    'module' => 'album',
                    'controller' => 'album',
                    'action' => 'index',
                ),
                'add' => array(
                    'label' => 'Add Album',
                    //'route' => 'album/add',
                    'module' => 'album',
                    'controller' => 'album',
                    'action' => 'add',
                ),
            ),
        ),
    ),
  ),
);
于 2013-01-16T15:05:55.180 回答