[英]How Sonata Admin Bundle in the left main menu to add custom page (NO CRUD! and not to the dashboard!)
如何在Sonata Admin Bundle 左側主菜單中添加自定義頁面?
沒有粗暴! 不要到儀表板!
單獨的獨立頁面,例如:統計,或幫助,或簡單的 html 頁面或自定義路由頁面。
謝謝!
最簡單的方法是重載SonataAdminBundle::standard_layout.html.twig
塊。 您正在尋找的是side_bar_before_nav和side_bar_after_nav 。 在這種情況下,您可以在菜單之前/之后添加鏈接,而不是在中間。
例如:
在src/yourbundle/Resources/views
創建文件standard_layout.html
{% extends "SonataAdminBundle::standard_layout.html.twig" %}
{% block side_bar_before_nav %}
<a href="#">Test</a>
{% endblock %}
添加一些 css 類以根據需要正確格式化鏈接。
您應該在app/Resources/config
(config.yml 或您自己的)中獲得了帶有 Sonata 配置選項的配置文件,在那里添加您的默認布局的名稱
sonata_admin:
title: Admin Panel
templates:
layout: YourOwnBundle::standard_layout.html.twig
在此之后,您必須清除緩存
$ php app/console cache:clear
另一種方法是使用您自己的控制器將其創建為管理類。 然后,您可以刪除所有路由並添加自己的路由並創建自己的操作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.