Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Zend framework2 zf2面包屑-子页面_Zend Framework2_Breadcrumbs - Fatal编程技术网

Zend framework2 zf2面包屑-子页面

Zend framework2 zf2面包屑-子页面,zend-framework2,breadcrumbs,Zend Framework2,Breadcrumbs,我的应用程序的配置有问题 我从模块的报告配置开始: 'corso' => array( 'type' => 'segment', 'options' => array( 'route' => '/corso[/:action[/:id]]', 'constraints' => array( 'id' => '[0-9]*', 'action' => '[a-zA-Z][a-zA-Z0-9_-]+'),

我的应用程序的配置有问题

我从模块的报告配置开始:

'corso' => array(
    'type' => 'segment',
    'options' => array(
        'route' => '/corso[/:action[/:id]]',
        'constraints' => array( 'id' => '[0-9]*', 'action' => '[a-zA-Z][a-zA-Z0-9_-]+'),
        'defaults' => array(
            'controller' => 'corso/Controller/corso',
            'action' => 'index',
        ),
    ),
),
控制器具有用于基本crud操作的索引、添加和编辑操作的常用方法

从配置文件中可以看到,添加和编辑操作不是子路由

我想买一个这种类型的面包屑

主页>索引操作控制器>添加/编辑操作

第一个和第二个元素是链接

这是面包屑的局部视图

<li><a href="<?php echo $this->url('home') ?>"><i class="iconfa-home"></i></a> <span class="separator"></span></li>
<?php $active = $container->findActive($navigation) ?>
<?php foreach($this->pages as $page): ?>
    <?php /* @var $page \Zend\Navigation\Page\Mvc */ ?>
    <?php if( ! $page->isActive()): ?>
        <li>
            <a href="<?php echo $page->getHref() ?>"><?php echo $page->getLabel() ?></a>
            <span class="divider">/</span>
        </li>
    <?php else: ?>
        <li class="active">
            <?php if($container->getLinkLast()): ?><a href="<?php echo $page->getHref() ?>"><?php endif ?>
                <?php echo $page->getLabel() ?>
                <?php if($container->getLinkLast()): ?><a href="<?php echo $page->getHref() ?>"><?php endif ?>
        </li>
    <?php endif ?>
<?php endforeach ?>
谢谢

编辑: 我对bredcrumbs使用zf2帮助程序

$this->navigation('navigation')->breadcrumbs()->setMinDepth(0)->setPartial(array('partial/breadcrumb', 'corso'));

Zend\Navigation Quick Start中有一个嵌套页面的示例:

在您的情况下,应该是这样的:

'navigation' => array(
    'default' => array(
        array(
            'label'  => 'corso',
            'route'  => 'corso',
            'action' => 'index',
            'pages' => array(
                array(
                    'label' => 'add action ',
                    'route' => 'corso',
                    'action' => 'add',
                ),
                array(
                    'label' => 'edit action ',
                    'route' => 'corso',
                    'action' => 'edit',
                ),
            ),
        ),
    ),
),

你试过zf2的面包屑助手吗?我用它。部分呈现用于自定义html。我想知道如何设置配置以获得我想要的结果
'navigation' => array(
    'default' => array(
        array(
            'label'  => 'corso',
            'route'  => 'corso',
            'action' => 'index',
            'pages' => array(
                array(
                    'label' => 'add action ',
                    'route' => 'corso',
                    'action' => 'add',
                ),
                array(
                    'label' => 'edit action ',
                    'route' => 'corso',
                    'action' => 'edit',
                ),
            ),
        ),
    ),
),