diff --git a/menu_block.module b/menu_block.module index 8e424b7..51b52a9 100644 --- a/menu_block.module +++ b/menu_block.module @@ -1,5 +1,7 @@ 'checkbox', + '#title' => $this->t('Link the title?'), + '#default_value' => $config['label_link'], + '#states' => [ + 'visible' => [ + ':input[name="settings[label_type]"]' => [ + ['value' => self::LABEL_ACTIVE_ITEM], + ['value' => self::LABEL_PARENT], + ['value' => self::LABEL_ROOT], + ['value' => self::LABEL_FIXED_PARENT ], + ['value' => 'initial_menu_item'], + ], + ], + ], + ]; + $form['style'] = [ '#type' => 'details', '#title' => $this->t('HTML and style options'), @@ -189,6 +208,7 @@ class MenuBlock extends SystemMenuBlock { $this->configuration['parent'] = $form_state->getValue('parent'); $this->configuration['suggestion'] = $form_state->getValue('suggestion'); $this->configuration['label_type'] = $form_state->getValue('label_type'); + $this->configuration['label_link'] = $form_state->getValue('label_link'); } /** @@ -299,6 +319,7 @@ class MenuBlock extends SystemMenuBlock { 'parent' => $this->getDerivativeId() . ':', 'suggestion' => strtr($this->getDerivativeId(), '-', '_'), 'label_type' => self::LABEL_BLOCK, + 'label_link' => 0, ]; } @@ -435,10 +456,17 @@ class MenuBlock extends SystemMenuBlock { * The menu item title. */ protected function getLinkTitleFromLink($link_id) { + $config = $this->configuration; $parameters = new MenuTreeParameters(); $menu = $this->menuTree->load($this->getDerivativeId(), $parameters); if ($link = $this->findLinkInTree($menu, $link_id)) { - return $link->link->getTitle(); + if ($config['label_link']) { + $block_link = Link::fromTextAndUrl($link->link->getTitle(), $link->link->getUrlObject())->toString(); + return Markup::create($block_link); + } + else { + return $link->link->getTitle(); + } } }