Skip to content

Commit

Permalink
Add root for list and nav templates
Browse files Browse the repository at this point in the history
  • Loading branch information
teppokoivula committed Mar 24, 2024
1 parent 0bcc9f7 commit d830bdb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions MarkupMenu.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
* @license Mozilla Public License v2.0 http://mozilla.org/MPL/2.0/
*/
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d830bdb

Please sign in to comment.