Соната Admin Bundle: изменить заголовок страницы - PullRequest
0 голосов
/ 29 августа 2018

Небольшой вопрос: как я могу изменить в Sonata Admin? Везде есть "Админ ...". И когда я перезаписываю страницу шаблоном сонаты, я получаю «Admin».

enter image description here

Thank х.

1 Ответ

0 голосов
/ 24 ноября 2018

Для достижения этой цели вы должны переопределить файл standard_layout.html.twig администратора Sonata.

Сначала определите файл в файле конфигурации администратора сонаты.

config/packages/sonata_admin.yaml

sonata_admin:    
    templates:
        layout: 'sonata_admin/layout.html.twig'

Создайте файл ветки с именем layout.html.twig внутри templates / sonata_admin / и просто вставьте блок 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 %}
...