浏览代码

Move the sidebar after the title header
Add the target name in the edit section

Thomas Rabaix 13 年之前
父节点
当前提交
7ffc35dd4f

+ 10 - 4
Admin/Admin.php

@@ -1689,7 +1689,7 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
      * Generates the breadcrumbs array
      *
      * @param string $action
-     * @param \Knp\Menu\MenuItem|null $menu
+     * @param \Knp\Menu\ItemInterface|null $menu
      * @return array
      */
     public function buildBreadcrumbs($action, MenuItemInterface $menu = null)
@@ -1723,6 +1723,7 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
             );
 
             return $childAdmin->buildBreadcrumbs($action, $child);
+
         } elseif ($this->isChild()) {
             if ($action != 'list') {
                 $menu = $menu->addChild(
@@ -1731,9 +1732,14 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
                 );
             }
 
-            $breadcrumbs = $menu->getBreadcrumbsArray(
-                $this->trans(sprintf('breadcrumb.link_%s_%s', $this->getClassnameLabel(), $action))
-            );
+            if ($this->hasSubject()) {
+                $breadcrumbs = $menu->getBreadcrumbsArray( (string) $this->getSubject());
+            } else {
+                $breadcrumbs = $menu->getBreadcrumbsArray(
+                    $this->trans(sprintf('breadcrumb.link_%s_%s', $this->getClassnameLabel(), $action))
+                );
+            }
+
         } else if ($action != 'list') {
             $breadcrumbs = $child->getBreadcrumbsArray(
                 $this->trans(sprintf('breadcrumb.link_%s_%s', $this->getClassnameLabel(), $action))

+ 1 - 1
Resources/translations/SonataAdminBundle.en.xliff

@@ -76,7 +76,7 @@
             </trans-unit>
             <trans-unit id="title_edit">
                 <source>title_edit</source>
-                <target>Edit</target>
+                <target>Edit "%name%"</target>
             </trans-unit>
             <trans-unit id="title_list">
                 <source>title_list</source>

+ 1 - 1
Resources/translations/SonataAdminBundle.fr.xliff

@@ -76,7 +76,7 @@
             </trans-unit>
             <trans-unit id="title_edit">
                 <source>title_edit</source>
-                <target>Éditer</target>
+                <target>Éditer "%name%"</target>
             </trans-unit>
             <trans-unit id="title_list">
                 <source>title_list</source>

+ 9 - 5
Resources/views/CRUD/base_edit.html.twig

@@ -11,6 +11,14 @@ file that was distributed with this source code.
 
 {% extends base_template %}
 
+{% block title %}
+    {% if admin.id(object) %}
+        {{ "title_edit"|trans({'%name%': object }, 'SonataAdminBundle') }}
+    {% else %}
+        {{ "title_create"|trans({}, 'SonataAdminBundle') }}
+    {% endif %}
+{% endblock%}
+
 {% block actions %}
     <div class="sonata-actions">
         <ul>
@@ -31,11 +39,7 @@ file that was distributed with this source code.
 
 {% block form %}
 
-    {% if admin.id(object) %}
-        {% set url = 'edit' %}
-    {% else %}
-        {% set url = 'create' %}
-    {% endif %}
+    {% set url = admin.id(object) ? 'edit' : 'create' %}
 
     {% if not admin.hasRoute(url)%}
         <div>

+ 17 - 16
Resources/views/standard_layout.html.twig

@@ -143,28 +143,29 @@ file that was distributed with this source code.
                 {%block actions %}{% endblock %}
             </div>
 
+            {% if _title is not empty or action is defined %}
+                <div class="page-header">
+                    <h1>
+                        {% if _title is not empty %}
+                            {{ _title|raw }}
+                        {% elseif action is defined %}
+                            {% for label, uri in admin.breadcrumbs(action) %}
+                                {% if loop.last  %}
+                                    {{ label }}
+                                {% endif %}
+                            {% endfor %}
+                        {% endif%}
+                    </h1>
+                </div>
+            {% endif%}
+
             {% if _side_menu is not empty %}
                 <div class="sidebar">
                     <div class="well sonata-ba-side-menu">{{ _side_menu|raw }}</div>
                 </div>
             {% endif %}
-            <div class="content">
 
-                {% if _title is not empty or action is defined %}
-                    <div class="page-header">
-                        <h1>
-                            {% if _title is not empty %}
-                                {{ _title|raw }}
-                            {% elseif action is defined %}
-                                {% for label, uri in admin.breadcrumbs(action) %}
-                                    {% if loop.last  %}
-                                        {{ label }}
-                                    {% endif %}
-                                {% endfor %}
-                            {% endif%}
-                        </h1>
-                    </div>
-                {% endif%}
+            <div class="content">
 
                 {% if _preview is not empty %}
                     <div class="sonata-ba-preview">{{ _preview|raw }}</div>