From d830bdb443abc433086de07e92cbfff48aeedf9d Mon Sep 17 00:00:00 2001 From: Teppo Koivula Date: Sun, 24 Mar 2024 12:55:32 +0200 Subject: [PATCH] Add root for list and nav templates --- CHANGELOG.md | 5 +++++ MarkupMenu.module.php | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e19fcd7..94f8339 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.2.0] - 2024-03-24 + +### Added +- "root", for the root page of the rendered list/menu, is now included in placeholders for list and nav templates. + ## [1.1.1] - 2023-11-02 ### Fixed diff --git a/MarkupMenu.module.php b/MarkupMenu.module.php index 2297892..b72a2c2 100644 --- a/MarkupMenu.module.php +++ b/MarkupMenu.module.php @@ -8,7 +8,7 @@ * MarkupMenu is a module for generating menu markup. See README.md for more details. * Some ideas and code in this module are based on the Markup Simple Navigation module. * - * @version 1.1.1 + * @version 1.2.0 * @author Teppo Koivula * @license Mozilla Public License v2.0 http://mozilla.org/MPL/2.0/ */ @@ -103,9 +103,9 @@ public function render(array $options = []): string { * Render menu from fixed array of items * * @param array $options Options for rendering + * @param array|null $root Root item for the menu * @param array $items Menu items * @param int $level Current tree level (depth) - * @param array|null $root Root item for the menu * @return string Rendered menu markup */ protected function renderArray(array $options = [], ?array $root, array $items, int $level = 1): string { @@ -123,6 +123,7 @@ protected function renderArray(array $options = [], ?array $root, array $items, $placeholders = [ 'level' => $level, 'root_page' => $options['root_page'], + 'root' => $root, ]; // generate list markup @@ -167,6 +168,7 @@ protected function renderTree(array $options = [], Page $root = null, PageArray $placeholders = [ 'level' => $level, 'root_page' => $options['root_page'], + 'root' => $root, ]; // generate list markup