Browse Source

Update for "Add a link to the breadcrumbs that retu..."

https://github.com/forkbb/forkbb/commit/2c4a9e407fd058936200938dd86a4c7816608dbc
Visman 2 years ago
parent
commit
a9ef39c152
2 changed files with 15 additions and 5 deletions
  1. 9 5
      app/Models/Page.php
  2. 6 0
      app/templates/layouts/crumbs.forkbb.php

+ 9 - 5
app/Models/Page.php

@@ -509,6 +509,7 @@ abstract class Page extends Model
     {
         $result = [];
         $active = true;
+        $ext    = null;
 
         foreach ($crumbs as $crumb) {
             // модель
@@ -520,7 +521,7 @@ abstract class Page extends Model
                         $name = ['%s', $name];
                     }
 
-                    $result[]     = [$crumb, $name, $active];
+                    $result[]     = [$crumb, $name, $active, $ext];
                     $active       = null;
                     $this->titles = $name;
 
@@ -529,7 +530,9 @@ abstract class Page extends Model
                     }
 
                     if ($crumb->linkCrumbExt) {
-                        $result[] = [$crumb->linkCrumbExt, '#', null];
+                        $ext = [$crumb->linkCrumbExt, '#'];
+                    } else {
+                        $ext = null;
                     }
 
                     $crumb = $crumb->parent;
@@ -539,18 +542,19 @@ abstract class Page extends Model
                 );
             // ссылка (передана массивом)
             } elseif (\is_array($crumb)) {
-                $result[]     = [$crumb[0], $crumb[1], $active];
+                $result[]     = [$crumb[0], $crumb[1], $active, $ext];
                 $this->titles = $crumb[1];
             // строка
             } else {
-                $result[]     = [null, (string) $crumb, $active];
+                $result[]     = [null, (string) $crumb, $active, $ext];
                 $this->titles = (string) $crumb;
             }
 
             $active = null;
+            $ext    = null;
         }
         // главная страница
-        $result[] = [$this->c->Router->link('Index'), 'Index', $active];
+        $result[] = [$this->c->Router->link('Index'), 'Index', $active, $ext];
 
         return \array_reverse($result);
     }

+ 6 - 0
app/templates/layouts/crumbs.forkbb.php

@@ -7,6 +7,9 @@
             <a class="f-crumb-a @if ($cur[2]) active" aria-current="page @endif" href="{{ $cur[0]->link }}" itemprop="item">
               <span itemprop="name">{!! __($cur[1]) !!}</span>
             </a>
+            @if ($cur[3])
+            &nbsp;[&nbsp;<a href="{{ $cur[3][0] }}">{{ $cur[3][1] }}</a>&nbsp;]
+            @endif
             <meta itemprop="position" content="{!! @iteration !!}">
           </li><!-- endinline -->
         @else
@@ -18,6 +21,9 @@
             @else
             <span @if ($cur[2]) class="active" @endif itemprop="name">{!! __($cur[1]) !!}</span>
             @endif
+            @if ($cur[3])
+            &nbsp;[&nbsp;<a href="{{ $cur[3][0] }}">{{ $cur[3][1] }}</a>&nbsp;]
+            @endif
             <meta itemprop="position" content="{!! @iteration !!}">
           </li><!-- endinline -->
         @endif