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.
This commit is contained in:
parent
dc8419cabc
commit
91c198cf0a
1 changed files with 6 additions and 5 deletions
11
MenuItem.php
11
MenuItem.php
|
@ -17,21 +17,22 @@ class MenuItem extends AbstractItem {
|
||||||
string $label = '',
|
string $label = '',
|
||||||
bool $strip_namespace = false
|
bool $strip_namespace = false
|
||||||
) {
|
) {
|
||||||
$this->type = $type;
|
$this->type = "childrenpages_$type";
|
||||||
if ( empty($label) ) {
|
if ( empty($label) ) {
|
||||||
$label = ucfirst($type);
|
$label = ucfirst($type);
|
||||||
}
|
}
|
||||||
$this->label = $label;
|
$this->label = $label;
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->setTargetFromType($strip_namespace);
|
$this->setTargetFromType($type, $strip_namespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the item target link from its type
|
* 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 $INFO;
|
||||||
global $plugin_controller;
|
global $plugin_controller;
|
||||||
$language = null;
|
$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
|
// 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
|
// "_main" is used to generate a link back to the main parent page
|
||||||
if ( $this->type !== '_main' ) {
|
if ( $this->type !== '_main' ) {
|
||||||
$target_path[] = $this->type;
|
$target_path[] = $type;
|
||||||
}
|
}
|
||||||
$this->id = implode(':', array_merge($target_path, $page_path));
|
$this->id = implode(':', array_merge($target_path, $page_path));
|
||||||
$this->params = [];
|
$this->params = [];
|
||||||
|
|
Loading…
Reference in a new issue