Fix breadcrumbs: stop double-filtering, add showHere support
Joomla core already handles showHome/showLast/homeText before passing $list to the template. Removed duplicate filtering that was breaking those settings. Added showHere param to control "You are here" label visibility. Bump to 03.09.11. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -10,49 +10,20 @@
|
|||||||
/**
|
/**
|
||||||
* Default layout override for mod_breadcrumbs.
|
* Default layout override for mod_breadcrumbs.
|
||||||
* Bootstrap 5 breadcrumb with schema.org BreadcrumbList markup.
|
* Bootstrap 5 breadcrumb with schema.org BreadcrumbList markup.
|
||||||
* Respects showHome, showLast, homeText module settings.
|
* Module settings (showHome, showLast, homeText) are handled by Joomla core
|
||||||
|
* before $list reaches this template.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
defined('_JEXEC') or die;
|
||||||
|
|
||||||
use Joomla\CMS\Factory;
|
|
||||||
use Joomla\CMS\Language\Text;
|
use Joomla\CMS\Language\Text;
|
||||||
use Joomla\CMS\Router\Route;
|
|
||||||
use Joomla\CMS\Uri\Uri;
|
|
||||||
|
|
||||||
Factory::getApplication()->getLanguage()->load('mod_breadcrumbs', JPATH_SITE);
|
|
||||||
|
|
||||||
$suffix = htmlspecialchars($params->get('moduleclass_sfx', ''), ENT_COMPAT, 'UTF-8');
|
$suffix = htmlspecialchars($params->get('moduleclass_sfx', ''), ENT_COMPAT, 'UTF-8');
|
||||||
$headerTag = htmlspecialchars($params->get('header_tag', 'h3'), ENT_COMPAT, 'UTF-8');
|
$headerTag = htmlspecialchars($params->get('header_tag', 'h3'), ENT_COMPAT, 'UTF-8');
|
||||||
$headerClass = htmlspecialchars($params->get('header_class', ''), ENT_COMPAT, 'UTF-8');
|
$headerClass = htmlspecialchars($params->get('header_class', ''), ENT_COMPAT, 'UTF-8');
|
||||||
$showHome = $params->get('showHome', 1);
|
$showHere = $params->get('showHere', 1);
|
||||||
$showLast = $params->get('showLast', 1);
|
|
||||||
$homeText = $params->get('homeText', '') ?: Text::_('MOD_BREADCRUMBS_HOME');
|
|
||||||
|
|
||||||
// Build filtered list respecting module settings
|
if (empty($list)) {
|
||||||
$items = [];
|
|
||||||
$count = count($list);
|
|
||||||
|
|
||||||
foreach ($list as $key => $item) {
|
|
||||||
// Skip Home item if showHome is off
|
|
||||||
if ($key === 0 && !$showHome) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Replace Home text if custom homeText is set
|
|
||||||
if ($key === 0 && $showHome) {
|
|
||||||
$item->name = $homeText;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip last item if showLast is off
|
|
||||||
if ($key === $count - 1 && !$showLast) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$items[] = $item;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($items)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -60,9 +31,12 @@ if (empty($items)) {
|
|||||||
<?php if ($module->showtitle) : ?>
|
<?php if ($module->showtitle) : ?>
|
||||||
<<?php echo $headerTag; ?> class="mod-breadcrumbs__title<?php echo $headerClass ? ' ' . $headerClass : ''; ?>"><?php echo $module->title; ?></<?php echo $headerTag; ?>>
|
<<?php echo $headerTag; ?> class="mod-breadcrumbs__title<?php echo $headerClass ? ' ' . $headerClass : ''; ?>"><?php echo $module->title; ?></<?php echo $headerTag; ?>>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
<?php if ($showHere) : ?>
|
||||||
|
<span class="mod-breadcrumbs__here"><?php echo Text::_('MOD_BREADCRUMBS_HERE'); ?></span>
|
||||||
|
<?php endif; ?>
|
||||||
<ol class="breadcrumb" itemscope itemtype="https://schema.org/BreadcrumbList">
|
<ol class="breadcrumb" itemscope itemtype="https://schema.org/BreadcrumbList">
|
||||||
<?php foreach ($items as $key => $item) : ?>
|
<?php foreach ($list as $key => $item) : ?>
|
||||||
<?php $isLast = ($key === array_key_last($items)); ?>
|
<?php $isLast = ($key === array_key_last($list)); ?>
|
||||||
<li class="breadcrumb-item<?php echo $isLast ? ' active' : ''; ?>" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"
|
<li class="breadcrumb-item<?php echo $isLast ? ' active' : ''; ?>" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"
|
||||||
<?php echo $isLast ? ' aria-current="page"' : ''; ?>>
|
<?php echo $isLast ? ' aria-current="page"' : ''; ?>>
|
||||||
<?php if (!$isLast && !empty($item->link)) : ?>
|
<?php if (!$isLast && !empty($item->link)) : ?>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
</server>
|
</server>
|
||||||
</updateservers>
|
</updateservers>
|
||||||
<name>MokoCassiopeia</name>
|
<name>MokoCassiopeia</name>
|
||||||
<version>03.09.10</version>
|
<version>03.09.11</version>
|
||||||
<scriptfile>script.php</scriptfile>
|
<scriptfile>script.php</scriptfile>
|
||||||
<creationDate>2026-03-26</creationDate>
|
<creationDate>2026-03-26</creationDate>
|
||||||
<author>Jonathan Miller || Moko Consulting</author>
|
<author>Jonathan Miller || Moko Consulting</author>
|
||||||
|
|||||||
Reference in New Issue
Block a user