Menu module: sites option not working

I’m trying to use a menu globally, across several sites. I’m excited about potentially accomplishing this with the Menu module.

This the code I am adding to my theme’s footer (used by all sites in the installation):

$globalMenu = $this->api()->searchOne('sites', ['id'=>3])->getContent();
echo $this->navMenu('my-menu-name', array('site' => $globalMenu));

It works in the site with id = 3 but not in any of the other sites.

I added a github issue to the module’s repo.

I’m also posting here because it’s possible I’m not getting the site representation correctly.

I don’t see anything obviously wrong there, assuming you know correctly which site ID you’re trying to get (you could also just use read with the ID). You might check to see whether what you’re getting as $globalMenu is a SiteRepresentation or null to get a better idea of where your problem might lie.

Thanks!
I changed searchOne to read. The site representation seems right because $globalMenu->slug() gives me the correct site slug. And I correctly see $globalMenu’s slug instead of the current site slug. I guess it’s good to know I’m getting the right site representation. Maybe, hopefully, @Daniel_KM will chime in about using the site option in his module.

Just a quick idea from a look at that code: what happens if you make a menu in the “other” site with the same name as the one you’re trying to read from site 3? It looks like there might be a check against the menu name that happens really early there, so it might be the case that if you do have a same-named menu in the current site, then the load of the menu from the other site would work.

Of course I’m just looking briefly at someone else’s module here but it’s worth a try both as a possible workaround and useful extra information to tell the developer if it works.

Hi @jflatnes, thanks for the suggestion. I created a menu in the “other” site with the same name as the menu in site 3. No joy.