希望您能帮助我解决这个问题。
我想要这样的面包屑:
首页/活动/活动名称/修改
我尝试了几种方法,但无法解决。 这就是我正在使用的功能。
private function setBreadcrumbLabelByRoute($activity)
{
$breadcrumb = $this->navigation->findBy('route', 'activity/edit');
$breadcrumb->setLabel($activity->getName());
}
我注意到的是:
如果我从函数中删除此$breadcrumb->setLabel($activity->getName());
,则将其作为面包屑:
首页/活动/修改
我的面包屑可以很好地工作,但是我需要两个标签的顺序不同! 可能吗?如果可能的话,我该如何解决呢?
路线
'routes' => [
'activity' => [
'type' => Segment::class,
'options' => [
'route' => '/activity',
'defaults' => [
'controller' => IndexController::class,
'action' => 'index',
],
],
'may_terminate' => true,
'child_routes' => [
'edit' => [
'type' => Segment::class,
'options' => [
'route' => '/:editId/edit',
'defaults' => [
'controller' => EditController::class,
'action' => 'index',
],
'constraints' => [
'editId' => '[0-9]+'
],
],
],
],
],
],
],
导航
'default' => [
[
'order' => 1,
'permission' => 'menu.activity',
'label' => _('Activities'),
'iconClass' => 'fa fa-calendar-o',
'route' => 'activity',
'pages' => [
'edit' => [
'label' => 'Test',
'module' => 'activity',
'controller' => EditController::class,
'route' => 'activity/edit',
'action' => 'index'
],
]
]
],
'breadcrumb' => [
[
'label' => _('Activities'),
'route' => 'activity',
'pages' => [
'edit' => [
'label' => _('Edit'),
'route' => 'activity/edit',
],
],
],
],
],
预先感谢