MenuManager

A plugin to enable management of menus within October CMS

Back to MenuManager Support

levmax198821693
levmax198821693

Hello. I have created menu with 5 parent nodes. The problem is that in 3 parent nodes all children are related to one page with slug e.g. {"activity":"holidays-for-hikers"}. In result, active class is always added to the first parent node. Even if you choose children in second or third menu item. Can you tell me please, how to resolve this issue? Or i have to resolve this problem in JS, finding proper parent with help of slug?

benfreke
benfreke

Hi

So just to confirm, you have a page "Holiday For Hikers" that you've added 3 different menu links to? Is it possible to give me a bit of a diagram of what you've done, like below? I just want to check how the calculations work in the onRender method.

  1. Parent 1 1.1 Hikers page
  2. Parent 2 2.1 Hikers page
  3. Parent 3
  4. Parent 4
  5. Parent 5 5.1 Hikers page.

When you click the 5.1 link, when the page loads 1. Parent 1 is marked as active?

levmax198821693
levmax198821693

Hi! http://joxi.ru/nAyMQGVco6naAZ Thera are 3 parents like (1) and (2) on the screenshot. Each has many children, related to 1 "activity" page, but with different page parameters. Each link is rendered properly e.g. /activities/holiday-for-hikers or /activities/holiday-for-cyclists etc. But when you go to page in second (2) list ( /activities/holiday-with-children) active parent must be Holiday Inspirations (2), but in fact it is Holiday Activities(1).

P.S. Plugin works well in case children are linked to different pages.
P.P.S. Thera are also parents (4) and (5) with links to other pages. And they become active properly.

benfreke
benfreke

Thanks for the image, that clears it up. Basically it's not possible with the current plugin for this to happen automatically. It looks for the active menu node based on name only.

And obviously setting the active node in the page won't work, as it's always the same page.

I believe that in the onRender method you can add a check for the Params when finding the active node. That's the only way to do it that I can see.

Let me know if you're not ok with making that change. I'm on mobile so not able to make and test that myself at the moment sorry.

levmax198821693
levmax198821693

Thank you! Yes, $params = reset($params); and ->where('parameters', 'like', '%'.$params.'%') has solved the issue.

benfreke
benfreke

Great to hear it works, I'll add that in for a future refactor. Looks like it was there in the past but was removed for some reason.

benfreke
benfreke

levmax198821693 said:

Thank you! Yes, $params = reset($params); and ->where('parameters', 'like', '%'.$params.'%') has solved the issue.

Out of curiousity, does ->where('parameters', (string)$params) work? Might be a few ms quicker on the DB query as it'll be doing an exact match.

1-7 of 7