MenuManager

A plugin to enable management of menus within October CMS

Back to MenuManager Support

deroccha
deroccha

First of all great plugin. I would like to show Menus depending on user status. If a page requires credentials should show up in navbar if user is logged in. Is there a way to make this?

benfreke
benfreke

No, that's not an option out of the box.

It should be fairly easy to add in though, but by default there is no code to do that.

deroccha
deroccha

Is it enough to modify Components template like setting up if else condition or needs depper coding?

benfreke
benfreke

It will need deeper coding than a simple if/else. Mainly because I don't know ahead of time which menu items link to pages, I've currently got it set up to only think about that on save and when rendered in the menu.

I might be wrong, as it's been a long time since I've changed any of this code, but I don't believe this is a simple change.

deroccha
deroccha

Yes I realised. I just started to hack to my needs but having many problems. I use rainlab.users Plugin to access/restrict a specific Page. On Menu Item save I try to parse if Page has the session component enabled or not and extending your table with a column I save a boolean. BUT what about if by editing a Page the component is getting removed?(not user friendly beacuse I need to update again the menu Item manually) Than on render I would use this new columns value to show/hide Menu, but how would I set up for example such a structure


--no session
  Login show
  User Dropdown hide
-- session exists
  Login hide
  Show username, dropdown->with user specific Menu Items.

On the other side as I see the plugin can show jut one nested Child or am I wrong? I did not saw any recusrion in the render template.

Last updated

benfreke
benfreke

I think you'll find that's the hard way to go about it.

What I think will be easier, is adding a method to the model. Currently, in the twig files it checks to make sure an item is enabled (i.e. line 4 of default.htm which is {% if primaryNav.enabled %}). Change that line to {% if primaryNav.isVisible() %}.

Then create a method called isVisible in the model, that does a check to pull in the page the menu item is referring to and whether the user can access it. Also make sure to keep a check in for enabled!

That won't be simple, but it's the most robust solution and has the advantage of being run at compile time so it should always work.

p.s. You won't need to hack the twig file, as you can just over-ride it in your template. p.p.s Version 2.0 (someday!) of this plugin will make that whole area extendable, so it's easier for developers like yourself to extend the plugin with custom functionality.

Last updated

deroccha
deroccha

thanks a lot I made it seems to work fine with isVisible and I check on flow enabled as well. Cool idea. Still not clear how to override twig file in my template. Different navigations are assigned to partials. Where do I do the override?

Last updated

benfreke
benfreke

template/partials/component/twigfilename, i.e. partials/menumanager/default.htm

Reference

deroccha
deroccha

thanks great!!

1-9 of 9