操作未呈现Zend_Navigation输出中



>我将以下数组传递给:

$container = new Zend_Navigation($fullmenu);
                    $this->view->navigation()->setContainer($container);

数组(转储print_r):

   Array (
    [0] => Array (
    [label] => menu
    [module] => admin
    [controller] => menu
    [action] => index
    [resource] =>
    [class] => settings hidden-xs hidden-sm
    )
    [1] => Array (
    [label] => Users
    [module] => admin
    [controller] => user
    [action] => index
    [resource] =>
    [pages] => Array (
    [0] => Array (
    [label] => Add User
    [module] => admin
    [controller] => user
    [action] => create
    [resource] => 
    )
    [1] => Array (
    [label] => List Users
    [module] => admin
    [controller] => user
    [action] => list
    [resource] =>
    )
    [2] => Array (
    [label] => Audit Trail
    [module] => admin
    [controller] => user
    [action] => trail
    [resource] =>
    )
    )
    [class] => dropdown-toggle
    )
    [2] => Array (
    [label] => reports
    [module] => admin
    [controller] => reports
    [action] => index
    [resource] =>
    [class] => settings hidden-xs hidden-sm
    )
    [3] => Array (
    [label] => tests
    [module] => admin
    [controller] => tests
    [action] => index
    [resource] =>
    [class] => settings hidden-xs hidden-sm
    )
    [4] => Array (
    [label] => Services
    [module] => admin
    [controller] => services
    [action] => index
    [resource] =>
    [class] => settings hidden-xs hidden-sm
    )
    [5] => Array (
    [label] => sports
    [module] => admin
    [controller] => sports
    [action] => index
    [resource] =>
    [pages] => Array (
    [0] => Array (
    [label] => Register New sports
    [module] => admin
    [controller] => sports
    [action] => register
    [resource] => portal:smme.register
    )
    )
    [class] => dropdown-toggle
    )
    )

但是菜单在输出中未正确呈现,因为生成的href's未显示在urlaction中。

换句话说,注册新运动仅显示:注册新运动

所以它们总是这样:/module/controller。例如。管理员/用户

如果注册了多个路由,则可能需要包含呈现 url 时使用的路由名称:

function includeRouteName(array $menuItems) {
    return array_map(function($menuItem) {
        if (!empty($menuItem['pages'])) {
            $menuItem['pages'] = includeRouteName($menuItem['pages']);
        }
        return new Zend_Navigation_Page_Mvc($menuItem + array(
            'route' => 'default' // assuming you have a route named 'default'
        ));
    }, $menuItems);
}
$fullmenu = includeRouteName($fullmenu);

相关内容

  • 没有找到相关文章