Skip to content

Commit

Permalink
Merge pull request #271 from esmero/ISSUE-270
Browse files Browse the repository at this point in the history
ISSUE-270: Enable the shortest (third option) Tarth for breadcrumbs
  • Loading branch information
DiegoPino authored May 25, 2023
2 parents 7eac5eb + 80fc079 commit d498c09
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Form/BreadcrumbSettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#options' => [
'longest' => 'Use first Longest parentship trail',
'smart' => 'Use the the most representative longest parentship trail based also on the shorter ones.',
'shortest' => 'Use the shorter one. Useful when all paths end in the same parent.',
],
'#default_value' => $breadcrumb_type->get('type'),
"#empty_value" => NULL,
Expand Down
3 changes: 3 additions & 0 deletions src/StrawberryFieldBreadcrumbBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ public function build(RouteMatchInterface $route_match) {
if ($this->configFactory->get('strawberryfield.breadcrumbs')->get('type') === 'longest') {
$longest_trail = !empty($trail_flat) ? max($trail_flat) : [];
}
elseif ($this->configFactory->get('strawberryfield.breadcrumbs')->get('type') === 'shortest') {
$longest_trail = !empty($trail_flat) ? min($trail_flat) : [];
}
else {
$longest_trail = $this->smartTrail($trail_flat);
}
Expand Down

0 comments on commit d498c09

Please sign in to comment.