hi all
this is my first post ever on this site (yeeeaay! ;) ), so please forgive me if I should have not created a new issue or if I do something else incredibly stupid or newbie-ish, but for the last couple of hours I have been pulling my hair out because of this one: on some links in my menu, the tokens are neatly replaced, as for others, nothing (not even the token gets removed if I check the box, so they just are not being treated...).
I traced down the problem to the menu_token_menu_links_discovered_alter(&$links) method (where the replace magic happens), and noticed that not every menu item on my site has been included in the $links parameter (some mumbo jumbo links like node_addform, and every internal (nod/somenumber) link are there, but none of my external (https://somesite/somepage) menu links seem to have made it to the links collection...
Am I doing something something wrong here, or am I overseeing something terribly obvious?
I tried to dive into the core code, but I don't seem to be able to locate the exact spot as to where the filtering of these menu items happens ("discovery" I think it is called if i'm not mistaken...)...
Or does the menu token module not treat these so called "external" (of type http://blabla) links?
the few strands of hair left standing on top of my head, are eternally grateful for any clarification/aid on the matter ;)
kind regards
Christophe
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | undiscoveredLinks.patch | 2.22 KB | peter.draucbaher |
Comments
Comment #2
peter.draucbaher commentedThanks a lot for this. It is bug.
$relevant_links = array_filter($links, function ($k) {
if (!isset($k['id'])) {
$k['id'] = 0;
}
return strpos($k['id'], 'menu_link_content:') === 0;
});
I am stripping menu items away. Have to repair it. It is too strict.
Have to investigate how external menus are handled in menu alter they are probably not menu_link_content...
Comment #3
peter.draucbaher commentedSomehow the system stores links inside menu_link_content_data as rediscover 0 and they do not get loaded in definitions.
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
// Get all custom menu links which should be rediscovered.
$entity_ids = $this->entityManager->getStorage('menu_link_content')->getQuery()
->condition('rediscover', TRUE)
->execute();
$plugin_definitions = [];
$menu_link_content_entities = $this->entityManager->getStorage('menu_link_content')->loadMultiple($entity_ids);
/** @var \Drupal\menu_link_content\MenuLinkContentInterface $menu_link_content */
foreach ($menu_link_content_entities as $menu_link_content) {
$plugin_definitions[$menu_link_content->uuid()] = $menu_link_content->getPluginDefinition();
}
return $plugin_definitions;
}
have to fix it.
Comment #4
peter.draucbaher commentedCheating a patch and will commit.
Comment #6
peter.draucbaher commentedComment #7
menwithbeards commentedHi Peter
patch in #4 works like a charm! I cannot thank you enough for this fix! Thank you thank you thank you!
keep up the amazing work and again, a very big thank you! (always a great feeling whilst pulling an all-nighter, to be able to take an issue off of the things-to-do-before-going-live-in-24-hours list ;)
Comment #8
peter.draucbaher commentedComment #10
letrollpoilu commentedI'm using the alpha3 version with Drupal 8.0.1 and this is still not working :(
I tried to apply the patch but this is not working: