[TikiWiki-commits] [Git][tikiwiki/tiki][27.x] [BP][ENH] Pagetop Hero Module: Enhance breadcrumb functionality with custom text and URL support.

"Alvin Bauma \(@alvinBM\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69ea169faaa6e_3818d24c-197@gitlab-sidekiq-low-urgency-cpu-bound-v2-75c97c766c-2ktqq.mail>

Alvin Bauma pushed to branch 27.x at Tiki Wiki CMS Groupware / Tiki


Commits:
9826bc39 by Alvin Bauma at 2026-04-23T14:54:52+02:00
[BP][ENH] Pagetop Hero Module: Enhance breadcrumb functionality with custom text and URL support.
---
* [ENH] Pagetop Hero Module: Enhance breadcrumb functionality with custom text and URL support.

See merge request tikiwiki/tiki!10029

- - - - -


2 changed files:

- modules/mod-func-pagetop_hero.php
- templates/modules/mod-pagetop_hero.tpl


Changes:

=====================================
modules/mod-func-pagetop_hero.php
=====================================
@@ -26,7 +26,13 @@ function module_pagetop_hero_info()
             'breadcrumbs' => [
                 'required' => false,
                 'name' => tr('Breadcrumbs'),
-                'description' => tr('Allows you to specify the navigation paths to arrive at the current page, Separate items to display with commas'),
+                'description' => tr('Allows you to specify the navigation paths to arrive at the current page. Separate items with commas. Use pipe (|) to specify custom text and URL: "Text|URL".'),
+            ],
+            'breadcrumbs_auto_link' => [
+                'required' => false,
+                'name' => tr('Breadcrumbs auto-link'),
+                'description' => tr('Automatically convert breadcrumb items to links. When enabled, each item becomes a link to itself unless pipe (|) is used to override. (y|n)'),
+                'default' => 'n'
             ],
             'content_position' => [
                 'required' => false,
@@ -70,15 +76,35 @@ function module_pagetop_hero($mod_reference, $module_params)
 
     $pagetitle = '';
     $breadcrumbs = [];
+    $auto_link = isset($module_params["breadcrumbs_auto_link"]) && $module_params["breadcrumbs_auto_link"] == 'y';
+
     if (isset($module_params["usepagename"]) && $module_params["usepagename"] == 'y') {
         $pagetitle = $_REQUEST['page'] ?? '';
-        $breadcrumbs[] = tra("Home");
-        $breadcrumbs[] = $pagetitle;
+        $breadcrumbs[] = ['text' => tra("Home"), 'url' => null];
+        $breadcrumbs[] = ['text' => $pagetitle, 'url' => null];
     } else {
         $pagetitle = $module_params["pagetitle"] ?? '';
         if (! empty($module_params["breadcrumbs"])) {
-            $breadcrumbs = isset($module_params["breadcrumbs"]) ? explode(",", $module_params["breadcrumbs"]) : [];
-            $breadcrumbs[] = $pagetitle;
+            $items = explode(",", $module_params["breadcrumbs"]);
+            foreach ($items as $item) {
+                $item = trim($item);
+                if (strpos($item, '|') !== false) {
+                    // Item has pipe: Text|URL
+                    list($text, $url) = explode('|', $item, 2);
+                    $breadcrumbs[] = ['text' => trim($text), 'url' => trim($url)];
+                } else {
+                    // Item without pipe
+                    if ($auto_link) {
+                        $breadcrumbs[] = ['text' => $item, 'url' => $item];
+                    } else {
+                        $breadcrumbs[] = ['text' => $item, 'url' => null];
+                    }
+                }
+            }
+            // Add page title as last breadcrumb (non-clickable)
+            if (! empty($pagetitle)) {
+                $breadcrumbs[] = ['text' => $pagetitle, 'url' => null];
+            }
         }
     }
 


=====================================
templates/modules/mod-pagetop_hero.tpl
=====================================
@@ -5,15 +5,21 @@
         <div class="content">
             <h1 class="pagetop-hero-title">{tr}{$pagetitle|escape}{/tr}</h1>
             {if count($breadcrumbs) gt 0}
-                <div class="breadcrumbs">
+                <ol class="breadcrumb">
                     {foreach from=$breadcrumbs item=item name=object }
                         {if $smarty.foreach.object.last}
-                            <span>{tr}{$item}{/tr}</span>
+                            <li class="breadcrumb-item active" aria-current="page">{tr}{$item.text}{/tr}</li>
                         {else}
-                            <b>{tr}{$item}{/tr}</b> /
+                            <li class="breadcrumb-item">
+                                {if $item.url neq null && $item.url neq ''}
+                                    <a href="{$item.url|escape}"><b>{tr}{$item.text|escape}{/tr}</b></a>
+                                {else}
+                                    {tr}{$item.text}{/tr}
+                                {/if}
+                            </li>
                         {/if}
                     {/foreach}
-                </div>
+                </ol>
             {else}
                 {if $description neq ''}
                     <p class="pagetop-hero-description">{tr}{$description|escape}{/tr}</p>
@@ -37,7 +43,7 @@
     }
 
     .pagetop-hero-title,
-    .breadcrumbs,
+    .breadcrumb,
     .pagetop-hero-description {
         text-align: center
     }
@@ -75,9 +81,24 @@
         -moz-filter: brightness(65%);
     }
 
-    .breadcrumbs,
-    .breadcrumbs a,
-    .breadcrumbs span {
+    .breadcrumb,
+    .breadcrumb a,
+    .breadcrumb .breadcrumb-item,
+    .breadcrumb .breadcrumb-item.active {
+        color: #fff !important;
+        background-color: transparent !important;
+    }
+
+    .breadcrumb a:hover {
+        color: #ddd !important;
+        text-decoration: underline;
+    }
+
+    .pagetop-hero .breadcrumb::before {
+        color: #fff !important;
+    }
+
+    .pagetop-hero .breadcrumb-item + .breadcrumb-item::before {
         color: #fff !important;
     }
 </style>
@@ -85,7 +106,7 @@
 {if $content_position eq 'topleft'}
     <style>
         .pagetop-hero-title,
-        .breadcrumbs,
+        .breadcrumb,
         .pagetop-hero-description {
             text-align: left
         }
@@ -99,7 +120,7 @@
 {if $content_position eq 'leftcenter'}
     <style>
         .pagetop-hero-title,
-        .breadcrumbs,
+        .breadcrumb,
         .pagetop-hero-description {
             text-align: left
         }
@@ -113,7 +134,7 @@
 {if $content_position eq 'topcenter'}
     <style>
         .pagetop-hero-title,
-        .breadcrumbs,
+        .breadcrumb,
         .pagetop-hero-description {
             text-align: center
         }
@@ -127,7 +148,7 @@
 {if $content_position eq 'topright'}
     <style>
         .pagetop-hero-title,
-        .breadcrumbs,
+        .breadcrumb,
         .pagetop-hero-description {
             text-align: right
         }
@@ -141,7 +162,7 @@
 {if $content_position eq 'bottomleft'}
     <style>
         .pagetop-hero-title,
-        .breadcrumbs,
+        .breadcrumb,
         .pagetop-hero-description {
             text-align: left
         }
@@ -155,7 +176,7 @@
 {if $content_position eq 'bottomcenter'}
     <style>
         .pagetop-hero-title,
-        .breadcrumbs,
+        .breadcrumb,
         .pagetop-hero-description {
             text-align: center
         }
@@ -169,7 +190,7 @@
 {if $content_position eq 'bottomright'}
     <style>
         .pagetop-hero-title,
-        .breadcrumbs,
+        .breadcrumb,
         .pagetop-hero-description {
             text-align: right
         }



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/9826bc3966ca80c9329b1872713974f2f9e3440b

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/9826bc3966ca80c9329b1872713974f2f9e3440b
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.