From a89c87caee17ba558bc99d54fb93ec965f967f01 Mon Sep 17 00:00:00 2001 From: Rizky Syazuli Date: Wed, 6 Nov 2019 19:42:25 +0700 Subject: [PATCH 1/3] additional classes and data attributes on link items to enable Bootstrap navbar with dropdown menu --- BigKahuna/BigKahunaTags.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/BigKahuna/BigKahunaTags.php b/BigKahuna/BigKahunaTags.php index 462ad1ca..9776002e 100755 --- a/BigKahuna/BigKahunaTags.php +++ b/BigKahuna/BigKahunaTags.php @@ -32,7 +32,9 @@ private function getItems($pages, $locale, $root = true) $id = ($this->getParam('id')) ? $this->getParam('id') : ""; $class = ($this->getParam('class')) ? $this->getParam('class') : "nav"; $itemClass = ($this->getParam('item_class')) ? $this->getParam('item_class') : "nav__item"; + $linkClass = ($this->getParam('link_class')) ? $this->getParam('link_class') : "nav__link"; $parentClass = ($this->getParam('parent_class')) ? $this->getParam('parent_class') : "nav__item--parent"; + $parentLinkClass = ($this->getParam('parent_link_class')) ? $this->getParam('parent_link_class') : "nav__item--toggle"; $submenu_class = ($this->getParam('submenu_class')) ? $this->getParam('submenu_class') : "submenu"; $submenu_item_class = ($this->getParam('submenu_item_class')) ? $this->getParam('submenu_item_class') : "submenu__item"; $activeClass = ($this->getParam('active_class')) ? $this->getParam('active_class') : "is--active"; @@ -51,9 +53,11 @@ private function getItems($pages, $locale, $root = true) } foreach ($pages as $page) { - $id = $page['id']; - $myClassname = ' ' . $page['classname']; - $isParent = $page['items'] ? ' ' . $parentClass : ''; + $id = $page['id']; + $myClassname = ' ' . $page['classname']; + $isParent = $page['items'] ? ' ' . $parentClass : ''; + $isParentLink = $page['items'] ? ' ' . $parentLinkClass: ''; + $parentAttributes = $page['items'] ? ' data-toggle="' . $parentClass . '" aria-haspopup="true" aria-expanded="false"': ''; if ($page['linktitle'] != '') { $myLinkTitle = $page['linktitle']; @@ -76,10 +80,10 @@ private function getItems($pages, $locale, $root = true) if ($page['type'] == 'Custom') { // A custom link - $html .= ''; + $html .= ''; } else { // An internal link - $html .= ''; + $html .= ''; } $html .= $page['title']; From 8009ecba9590663401d4caaebf5f2897fcc42946 Mon Sep 17 00:00:00 2001 From: Rizky Syazuli Date: Wed, 6 Nov 2019 19:58:20 +0700 Subject: [PATCH 2/3] revise data-toggle attribute to 'dropdown' --- BigKahuna/BigKahunaTags.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BigKahuna/BigKahunaTags.php b/BigKahuna/BigKahunaTags.php index 9776002e..1d443c27 100755 --- a/BigKahuna/BigKahunaTags.php +++ b/BigKahuna/BigKahunaTags.php @@ -57,7 +57,7 @@ private function getItems($pages, $locale, $root = true) $myClassname = ' ' . $page['classname']; $isParent = $page['items'] ? ' ' . $parentClass : ''; $isParentLink = $page['items'] ? ' ' . $parentLinkClass: ''; - $parentAttributes = $page['items'] ? ' data-toggle="' . $parentClass . '" aria-haspopup="true" aria-expanded="false"': ''; + $parentAttributes = $page['items'] ? ' data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"': ''; if ($page['linktitle'] != '') { $myLinkTitle = $page['linktitle']; From d882f8d23edc1976776152615cfde9a16c05efb1 Mon Sep 17 00:00:00 2001 From: Rizky Syazuli Date: Wed, 6 Nov 2019 20:03:25 +0700 Subject: [PATCH 3/3] update docs to reflect new changes --- DOCUMENTATION.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 14e87e63..53ef4116 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -59,9 +59,15 @@ The class for feedback for the current page. Defaults to 'is--active'. This clas **item\_class** The class for every root li. Defaults to 'nav__item'. +**link\_class** +The class for every link items. Defaults to 'nav__link'. + **parent\_class** The class for li items with a submenu. Defaults to 'nav__item--parent'. +**parent\_link\_class** +The class for link items with a submenu. Defaults to 'nav__item--toggle'. + ### A submenu list **submenu\_class** The class for every ul element inside a list item following a link. The default is 'submenu'. @@ -71,4 +77,5 @@ The class for every li element in a submenu. The default is 'submenu__item'. ### Stuff not on the menu * Custom links to external sites get a `rel="external"` on the link tag. +* Links with submenu items get a `data-toggle="dropdown"` to support Bootstrap dropdown menus. * Since the 'is--active' class is added to an li, it's best to use something like `.is--active > a` in your stylesheet for feedback classes. That way the submenu links don't inherit the active style.