3

Can a component view be configured to show a only a subset of available User Groups when adding it to a menu?

My component has a front-end view that must never be allowed to be viewed by anyone except users which are within a custom front-end User Group. I understand that the person adding the menu item should "know" what they're doing, but I'm interested to know if this can be done as well.

3

Not in a standard sense, i.e. the normal UI provided by Joomla. (Presuming you're talking about when an actual menu item is created here?) Extensions don't get a chance to run code when a menu item is created so, short answer: no.

I would normally suggest a plug-in but looking at com_menu I can only see two JEventDispatcher calls and they aren't very useful.

In /administrator/components/com_menus/models/menutypes.php you have:

// Allow a system plugin to insert dynamic menu types to the list shown in menus:
JEventDispatcher::getInstance()->trigger('onAfterGetMenuTypeOptions', array(&$list, $this));

And in /administrator/components/com_menus/views/items/view.html.php you have:

// Allow a system plugin to insert dynamic menu types to the list shown in menus:
JEventDispatcher::getInstance()->trigger('onBeforeRenderMenuItems', array($this));

Looking a layer deeper, the menu item class MenusModelItem extends JModelAdmin the good thing here is that JModelAdmin does trigger an onContentChangeState() event which you could trap and dis-allow anyone try to set your view to published if the user group is wrong.

Having said that, I wouldn't be doing that. Menu's are just paths and easy to guess in our SEO/SEF world. The right place to do it is in the component/view itself, rejecting anyone that isn't in the right group. You can do this either silently bouncing users back to the home page or throw a 404.

  • Good God - thank you so much for that in-depth answer - it seemed a little against the grain, but with all the new ACL, I thought it might be one of those little used features. – GDP Jul 14 '14 at 13:34
  • No problem, glad to help. :D – Craig Jul 14 '14 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.