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:
vv221 2020-04-05 15:25:56 +02:00
parent dc8419cabc
commit 91c198cf0a

View file

@ -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 = [];