简体   繁体   English

在显示视图中显示侧边栏-Sonata管理员捆绑包

[英]Show sidebar in show view - Sonata admin bundle

Hello i would like to show the sidebar in sonata admin bundle, however i can't find a good example, this is the code i use to show it in the edit mode: 您好,我想在Sonata管理员捆绑包中显示侧边栏,但是我找不到一个很好的例子,这是我用来在编辑模式下显示它的代码:

protected function configureSideMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null) {
    if (!$childAdmin && !in_array($action, array('edit'))) {
        return;
    }

    $admin = $this->isChild() ? $this->getParent() : $this;
    $id = $admin->getRequest()->get('id');

    $menu->addChild(
        'view',
        array('uri' => $admin->generateUrl('edit', array('id' => $id)))
    );

    $menu->addChild(
        'replies',
        array('uri' => $admin->generateUrl('sonata.admin.module.application.replies.list', array('id' => $id)))
    );
}

however i would like to make it appear in the show view since i am displaying that as default because the form should not be editable. 但是我想使其显示在显示视图中,因为我将其默认显示,因为该表格不可编辑。

This is my configureShowFields 这是我的configureShowFields

protected function configureShowFields(ShowMapper $showMapper) {
    $showMapper
        ->add('application')
        ->add('denied')
        ->add('details', 'string', array('template' => 'MyBundle:Admin:jsonToTable.html.twig'))
    ;
}

Found it, just add the correct action to the configureSideMenu function 找到它,只需将正确的操作添加到configureSideMenu函数即可

protected function configureSideMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
{
    if (!$childAdmin && !in_array($action, array('edit', 'show'))) {
        return;
    }
    $admin = $this->isChild() ? $this->getParent() : $this;
    $id = $admin->getRequest()->get('id');

    $menu->addChild(
       'view',
        array('uri' => $admin->generateUrl('show', array('id' => $id)))
    );

    $menu->addChild(
        'replies',
        array('uri' => $admin->generateUrl('sonata.admin.module.application.replies.list', array('id' => $id)))
    );
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Symfony 2 Sonata Admin Bundle的节目动作不起作用 - The show action of Symfony 2 Sonata Admin Bundle is not working 访问拒绝执行动作显示和角色VIEW:显示配置文件sonata-admin-bundle - Access Denied to the action show and role VIEW : show profile sonata-admin-bundle Sonata管理员捆绑包过滤器显示角色用户的实体 - Sonata Admin Bundle filter show entity from role user Sonata Admin +显示列表视图中的所有项目(不是每页) - Sonata Admin + show all items on list view (not per page) Sonata Admin Bundle的编辑视图中的自定义操作 - Custom action in the edit view of sonata admin Bundle Sonata 管理包:显示角色明智的侧边栏菜单 - Sonata admin bundle: display role wise sidebar menu Sonata管理员捆绑包显示子表列表以及父表的“添加/编辑”屏幕 - Sonata Admin Bundle Show Child table list along with Add/Edit screen of parent table 如何在Sonata Admin Bundle中的列表操作上显示类型为array的Entity值? - How to show a Entity value of type array on list action in Sonata Admin Bundle? Sonata Admin Bundle 4.5 ListView:再次直接链接到 /edit 而不是 /show - Sonata Admin Bundle 4.5 ListView: Link again directly to /edit instead of /show 在Symfony Bundle的视图中显示Sonata Admin Bundle - Display the Sonata Admin Bundle inside a view of a Symfony Bundle
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM