Skip to content

Commit

Permalink
fix: exclude hidden pages from automatic breadcrumb generation
Browse files Browse the repository at this point in the history
references: #114
  • Loading branch information
brotkrueml committed Jun 2, 2023
1 parent d0cecc6 commit e27c882
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Classes/EventListener/AddBreadcrumbList.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public function __invoke(InitialiseTypesEvent $event): void
break;
}

if ($page['hidden'] ?? false) {
continue;
}

if ($page['nav_hide'] ?? false) {
continue;
}
Expand Down
34 changes: 34 additions & 0 deletions Tests/Unit/EventListener/AddBreadcrumbListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,40 @@ public function rootLineProvider(): iterable
'{"@context":"https://schema.org/","@type":"BreadcrumbList","itemListElement":{"@type":"ListItem","item":{"@type":"WebPage","@id":"https://example.org/the-page/"},"name":"A page","position":"1"}}',
];

yield 'Rootline with a hidden page' => [
[
3 => [
'uid' => 3,
'doktype' => PageRepository::DOKTYPE_DEFAULT,
'title' => 'A page',
'nav_title' => '',
'nav_hide' => '0',
'hidden' => '1',
'is_siteroot' => '0',
'tx_schema_webpagetype' => '',
],
2 => [
'uid' => 2,
'doktype' => PageRepository::DOKTYPE_DEFAULT,
'title' => 'A page',
'nav_title' => '',
'nav_hide' => '0',
'is_siteroot' => '0',
'tx_schema_webpagetype' => '',
],
1 => [
'uid' => 1,
'doktype' => PageRepository::DOKTYPE_DEFAULT,
'title' => 'Site root page',
'nav_title' => '',
'nav_hide' => '0',
'is_siteroot' => '1',
'tx_schema_webpagetype' => '',
],
],
'{"@context":"https://schema.org/","@type":"BreadcrumbList","itemListElement":{"@type":"ListItem","item":{"@type":"WebPage","@id":"https://example.org/the-page/"},"name":"A page","position":"1"}}',
];

yield 'Rootline with siteroot not on first level' => [
[
2 => [
Expand Down

0 comments on commit e27c882

Please sign in to comment.