[英]Sonata Admin Bundle : change page title
You have to override Sonata admin's standard_layout.html.twig file to achieve this.您必须覆盖 Sonata 管理员的 standard_layout.html.twig 文件才能实现此目的。
First, define the file in sonata admin config file.首先,在 Sonata 管理配置文件中定义文件。
config/packages/sonata_admin.yaml
sonata_admin:
templates:
layout: 'sonata_admin/layout.html.twig'
Create a twig file named layout.html.twig inside templates/sonata_admin/ and just paste the sonata_head_title block from the bundle.在templates/sonata_admin/ 中创建一个名为layout.html.twig 的twig文件,然后粘贴bundle 中的sonata_head_title块。
{% extends '@SonataAdmin/standard_layout.html.twig' %}
{% block sonata_head_title %}
{{ 'Admin'|trans({}, 'SonataAdminBundle') }} //remove this line to get rid of text "Admin"
{% if _title is not empty %}
{{ _title|striptags|raw }}
{% else %}
{% if action is defined %}
-
{% for menu in breadcrumbs_builder.breadcrumbs(admin, action) %}
{% if not loop.first %}
{% if loop.index != 2 %}
>
{% endif %}
{%- set translation_domain = menu.extra('translation_domain', 'messages') -%}
{%- set label = menu.label -%}
{%- if translation_domain is not same as(false) -%}
{%- set label = label|trans(menu.extra('translation_params', {}), translation_domain) -%}
{%- endif -%}
{{ label }}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{% endblock %}
You can easy do that by override the sonata admin file translation您可以通过覆盖奏鸣曲管理文件翻译轻松做到这一点
1- Create folder structure in traslations like this : 1- 在这样的 traslations 中创建文件夹结构:
2- then in the SonataAdminBundle.[your-language-code].yml
file add : 2-然后在
SonataAdminBundle.[your-language-code].yml
文件中添加:
Admin: "You Custom title Here"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.