From 91c198cf0ab6ab27cf3bfb0c07d7eb557de9e77b Mon Sep 17 00:00:00 2001 From: vv221 Date: Sun, 5 Apr 2020 15:25:56 +0200 Subject: [PATCH] Add a prefix to the type of menu items generated by this plugin The prefix used is "childrenpages_". This should make it easier for template builders to identify the menu items added by this plugin. --- MenuItem.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/MenuItem.php b/MenuItem.php index b11abd8..76daf4e 100644 --- a/MenuItem.php +++ b/MenuItem.php @@ -17,21 +17,22 @@ class MenuItem extends AbstractItem { string $label = '', bool $strip_namespace = false ) { - $this->type = $type; + $this->type = "childrenpages_$type"; if ( empty($label) ) { $label = ucfirst($type); } $this->label = $label; parent::__construct(); - $this->setTargetFromType($strip_namespace); + $this->setTargetFromType($type, $strip_namespace); } /** * Set the item target link from its type * - * @param bool $strip_namespace + * @param string $type + * @param bool $strip_namespace */ - protected function setTargetFromType(bool $strip_namespace) : void { + protected function setTargetFromType(string $type, bool $strip_namespace) : void { global $INFO; global $plugin_controller; $language = null; @@ -62,7 +63,7 @@ class MenuItem extends AbstractItem { // Add namespace of the target child page, unless the special value "_main" has been used // "_main" is used to generate a link back to the main parent page if ( $this->type !== '_main' ) { - $target_path[] = $this->type; + $target_path[] = $type; } $this->id = implode(':', array_merge($target_path, $page_path)); $this->params = [];