From 81e89db88c7a0f32b714e097161a0656bc845692 Mon Sep 17 00:00:00 2001 From: Jonathan Miller <230051081+jmiller-moko@users.noreply.github.com> Date: Sat, 4 Apr 2026 11:28:45 -0500 Subject: [PATCH] Scope TOC to article body only and use language string for title - Move data-toc-scope from outer column to .article-content div so the TOC only sees headings inside the article body, ignoring page headers and article titles. - Pass $scope explicitly in the JS auto-init so headings outside the article content are never picked up. - Replace hardcoded article title in TOC heading with a TPL_MOKOCASSIOPEIA_TOC_TITLE language string ("Table of Contents"). - Add Text use statement to both toc-left.php and toc-right.php. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/html/com_content/article/toc-left.php | 7 ++++--- src/html/com_content/article/toc-right.php | 7 ++++--- src/language/en-GB/tpl_mokocassiopeia.ini | 1 + src/language/en-US/tpl_mokocassiopeia.ini | 1 + src/media/vendor/bootstrap-toc/bootstrap-toc.js | 3 ++- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/html/com_content/article/toc-left.php b/src/html/com_content/article/toc-left.php index 1310b3a..df6a95c 100644 --- a/src/html/com_content/article/toc-left.php +++ b/src/html/com_content/article/toc-left.php @@ -12,6 +12,7 @@ defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Associations; +use Joomla\CMS\Language\Text; use Joomla\CMS\Layout\LayoutHelper; // Load Bootstrap TOC assets @@ -36,13 +37,13 @@ $assocParam = (Associations::isEnabled() && $params->get('show_associations'));
-
+
params->get('show_page_heading')) : ?> @@ -84,7 +85,7 @@ $assocParam = (Associations::isEnabled() && $params->get('show_associations')); item->tags->itemTags); ?> -
+
item->text; ?>
diff --git a/src/html/com_content/article/toc-right.php b/src/html/com_content/article/toc-right.php index d54c4b8..21a1ae7 100644 --- a/src/html/com_content/article/toc-right.php +++ b/src/html/com_content/article/toc-right.php @@ -12,6 +12,7 @@ defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Associations; +use Joomla\CMS\Language\Text; use Joomla\CMS\Layout\LayoutHelper; // Load Bootstrap TOC assets @@ -33,7 +34,7 @@ $assocParam = (Associations::isEnabled() && $params->get('show_associations'));
-
+
params->get('show_page_heading')) : ?> @@ -75,7 +76,7 @@ $assocParam = (Associations::isEnabled() && $params->get('show_associations')); item->tags->itemTags); ?> -
+
item->text; ?>
@@ -101,7 +102,7 @@ $assocParam = (Associations::isEnabled() && $params->get('show_associations'));
diff --git a/src/language/en-GB/tpl_mokocassiopeia.ini b/src/language/en-GB/tpl_mokocassiopeia.ini index 292bd17..945950b 100644 --- a/src/language/en-GB/tpl_mokocassiopeia.ini +++ b/src/language/en-GB/tpl_mokocassiopeia.ini @@ -66,6 +66,7 @@ TPL_MOKOCASSIOPEIA_FONT_NOTE_TEXT="Loading fonts from external sources might be ; ===== Header & navigation (Theme tab) ===== TPL_MOKOCASSIOPEIA_STICKY_LABEL="Sticky Header" TPL_MOKOCASSIOPEIA_BACKTOTOP="Back to Top" +TPL_MOKOCASSIOPEIA_TOC_TITLE="Table of Contents" TPL_MOKOCASSIOPEIA_BACKTOTOP_LABEL="Back-to-top Link" TPL_MOKOCASSIOPEIA_TOC="Table of Contents" diff --git a/src/language/en-US/tpl_mokocassiopeia.ini b/src/language/en-US/tpl_mokocassiopeia.ini index 177044f..f70f948 100644 --- a/src/language/en-US/tpl_mokocassiopeia.ini +++ b/src/language/en-US/tpl_mokocassiopeia.ini @@ -66,6 +66,7 @@ TPL_MOKOCASSIOPEIA_FONT_NOTE_TEXT="Loading fonts from external sources might be ; ===== Header & navigation (Theme tab) ===== TPL_MOKOCASSIOPEIA_STICKY_LABEL="Sticky Header" TPL_MOKOCASSIOPEIA_BACKTOTOP="Back to Top" +TPL_MOKOCASSIOPEIA_TOC_TITLE="Table of Contents" TPL_MOKOCASSIOPEIA_BACKTOTOP_LABEL="Back-to-top Link" TPL_MOKOCASSIOPEIA_TOC="Table of Contents" diff --git a/src/media/vendor/bootstrap-toc/bootstrap-toc.js b/src/media/vendor/bootstrap-toc/bootstrap-toc.js index e1423e1..746f109 100644 --- a/src/media/vendor/bootstrap-toc/bootstrap-toc.js +++ b/src/media/vendor/bootstrap-toc/bootstrap-toc.js @@ -178,7 +178,8 @@ $(function() { $('nav[data-toggle="toc"]').each(function(i, el) { var $nav = $(el); - Toc.init($nav); + var $scope = $('[data-toc-scope]'); + Toc.init({ $nav: $nav, $scope: $scope.length ? $scope : $(document.body) }); }); }); })(jQuery);