@@ -29,24 +29,12 @@ In addition to adding to the end of the trail, you can do a variety of operation
2929 ['controller' => 'products', 'action' => 'index']
3030 );
3131
32- // Add multiple crumbs at the end of the trail
33- $this->Breadcrumbs->add([
34- ['title' => 'Products', 'url' => ['controller' => 'products', 'action' => 'index']],
35- ['title' => 'Product name', 'url' => ['controller' => 'products', 'action' => 'view', 1234]],
36- ]);
37-
3832 // Prepended crumbs will be put at the top of the list
3933 $this->Breadcrumbs->prepend(
4034 'Products',
4135 ['controller' => 'products', 'action' => 'index']
4236 );
4337
44- // Prepend multiple crumbs at the top of the trail, in the order given
45- $this->Breadcrumbs->prepend([
46- ['title' => 'Products', 'url' => ['controller' => 'products', 'action' => 'index']],
47- ['title' => 'Product name', 'url' => ['controller' => 'products', 'action' => 'view', 1234]],
48- ]);
49-
5038 // Insert in a specific slot. If the slot is out of
5139 // bounds, an exception will be raised.
5240 $this->Breadcrumbs->insertAt(
@@ -73,6 +61,37 @@ In addition to adding to the end of the trail, you can do a variety of operation
7361 ['controller' => 'products', 'action' => 'index']
7462 );
7563
64+ Adding Multiple Crumbs
65+ ----------------------
66+
67+ .. versionadded :: 5.3
68+
69+ You can add or prepend multiple crumbs at once using ``addMany() `` and
70+ ``prependMany() ``. These methods accept an array of crumbs and optional shared
71+ options that apply to all crumbs::
72+
73+ // Add multiple crumbs at the end of the trail
74+ $this->Breadcrumbs->addMany([
75+ ['title' => 'Products', 'url' => ['controller' => 'products', 'action' => 'index']],
76+ ['title' => 'Product name', 'url' => ['controller' => 'products', 'action' => 'view', 1234]],
77+ ]);
78+
79+ // Prepend multiple crumbs at the top of the trail, in the order given
80+ $this->Breadcrumbs->prependMany([
81+ ['title' => 'Products', 'url' => ['controller' => 'products', 'action' => 'index']],
82+ ['title' => 'Product name', 'url' => ['controller' => 'products', 'action' => 'view', 1234]],
83+ ]);
84+
85+ // Add multiple crumbs with shared options applied to all
86+ $this->Breadcrumbs->addMany([
87+ ['title' => 'Home', 'url' => '/'],
88+ ['title' => 'Products', 'url' => '/products'],
89+ ['title' => 'Category'],
90+ ], ['class' => 'breadcrumb-item']);
91+
92+ The shared options are merged with any options specified on individual crumbs,
93+ with individual crumb options taking precedence.
94+
7695Using these methods gives you the ability to work with CakePHP's 2-step
7796rendering process. Since templates and layouts are rendered from the inside out
7897(meaning, included elements are rendered first), this allows you to define
@@ -190,7 +209,7 @@ when you want to transform the crumbs and overwrite the list::
190209 return $crumb;
191210 })->toArray();
192211
193- $this->Breadcrumbs->reset()->add ($crumbs);
212+ $this->Breadcrumbs->reset()->addMany ($crumbs);
194213
195214.. meta ::
196215 :title lang=en: BreadcrumbsHelper
0 commit comments