Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.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
索纳塔(Symfony)中的自定义菜单,无需创建新实体_Symfony_Sonata Admin - Fatal编程技术网

索纳塔(Symfony)中的自定义菜单,无需创建新实体

索纳塔(Symfony)中的自定义菜单,无需创建新实体,symfony,sonata-admin,Symfony,Sonata Admin,我不熟悉stackoverflow(这是我的第一篇文章),也不熟悉Symfony2和SonataAdmin(一个捆绑包),我有一个小问题(我搜索了,但找不到有效的解决方案) 我已经创建了一些实体,它们都出现在仪表板左侧的菜单中,这一切都很正常 但我想做的是添加选项卡而不创建实体,当您单击此菜单选项卡时,只需更改右侧的内容!可能吗?谢谢在您自己的管理包的资源/视图目录中创建一个空模板 (例如,custom_layout.html.twig) 然后,在你的app/config中打开config.ym

我不熟悉stackoverflow(这是我的第一篇文章),也不熟悉Symfony2和SonataAdmin(一个捆绑包),我有一个小问题(我搜索了,但找不到有效的解决方案)

我已经创建了一些实体,它们都出现在仪表板左侧的菜单中,这一切都很正常


但我想做的是添加选项卡而不创建实体,当您单击此菜单选项卡时,只需更改右侧的内容!可能吗?谢谢

在您自己的管理包的
资源/视图
目录中创建一个空模板
(例如,
custom_layout.html.twig

然后,在你的
app/config
中打开
config.yml
(或者
sonata/admin.yml
,如果你有单独的sonata配置文件)并添加(或者更新,如果存在)以下内容:

sonata_admin:
    # ...
    templates:
        layout: YourBundle::custom_layout.html.twig
最后,打开空模板,使其从
标准布局.html.twig

覆盖好的块, 并添加自定义菜单(复制现有菜单的标记):

{%extends'SonataAdminBundle::standard_layout.html.twig%}
{%block side_bar_后_nav%}
  • {%endblock%}

    就这些。

    我应该插入屏幕截图吗?
    {% extends 'SonataAdminBundle::standard_layout.html.twig' %}
    
    {% block side_bar_after_nav %}
    <li class="treeview">
      <a href="#">
        <i class="fa fa-folder"></i>
        <span>Custom Menu</span>
        <i class="fa pull-right fa-angle-left"></i>
      </a>
      <ul class="treeview-menu">
        <li class="first last">
          <a href="{{ path('custom_route') }}">
            <i class="fa fa-angle-double-right"></i>
            Custom link
          </a>
        </li>
      </ul>
    </li>
    {% endblock %}