Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions modules/tide_breadcrumbs/tide_breadcrumbs.module
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Tide Breadcrumbs module functionality.
*/

use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
Expand Down Expand Up @@ -74,11 +75,19 @@ function tide_breadcrumbs_node_view(array &$build, NodeInterface $node, EntityVi
if (!empty($trail)) {
$breadcrumb_items = [];
foreach ($trail as $item) {
$breadcrumb_items[] = [
'#type' => 'link',
'#title' => $item['title'],
'#url' => Url::fromUserInput($item['url']),
];
if (!empty($item['title'] && !empty($item['url']))) {
if (UrlHelper::isExternal($item['url'])) {
$url = Url::fromUri($item['url']);
}
else {
$url = Url::fromUserInput($item['url']);
}
$breadcrumb_items[] = [
'#type' => 'link',
'#title' => $item['title'],
'#url' => $url,
];
}
}

// Build the render array with a heading and horizontal layout.
Expand Down
Loading