Restrict component submenu items using ACL ? Topic is solved

Moderators: mandville, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
david0058
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 103
Joined: Wed Jan 20, 2016 10:58 pm

Restrict component submenu items using ACL ?

Post by david0058 » Fri Apr 22, 2022 10:56 am

Hi,

I have a backend component with five submenu options defined in <menu> entries in the <submenu> node of the component.xml. I would like all of these to be visible to superusers (core.admin) but only the first three to be shown to administrators (core.manage).

Is this possible ? I can clearly block access to the underlying functions in the code by checking the access permissions but I'd prefer to just not display menu items if the users don't have access to them.

Thanks,

David

J3.10.3
Last edited by david0058 on Fri Apr 22, 2022 12:42 pm, edited 1 time in total.

david0058
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 103
Joined: Wed Jan 20, 2016 10:58 pm

Re: Restrict component submenu items using ACL ?

Post by david0058 » Fri Apr 22, 2022 12:24 pm

It seems to be something to do with putting the logic in helpers/xxx.php in the addSubmenu($vName) function:

Code: Select all

 {   
        $canDo = JHelperContent::getActions('com_xxx');

        if ($canDo->get('core.edit.own')){
            JSubMenuHelper::addEntry( JText::_('COM_XXX_SUBMENU_OPTION1'), 'index.php?option=com_xxx&view=option1', $vName == 'option1');
            JHtmlSidebar::addEntry( JText::_('COM_XXX_SUBMENU_OPTION1'), 'index.php?option=com_xxx&view=option1, $vName == 'option1');
        }
     }
However while this is fine once the component code is actually run, I don't see how to tell Joomla what to display in the main menu when a user logs in but before they run anything ...

User avatar
AMurray
Joomla! Exemplar
Joomla! Exemplar
Posts: 9747
Joined: Sat Feb 13, 2010 7:35 am
Location: Australia

Re: Restrict component submenu items using ACL ?

Post by AMurray » Fri Apr 22, 2022 10:28 pm

I thought the Administrator menu system worked in a similar way as the front-end (as far as the ACL is concerned).

Wouldn't you simply place those users wanting access to those three admin items in the "Administrator" user group?
Regards - A Murray
General Support Moderator

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44097
Joined: Sat Apr 05, 2008 9:58 pm

Re: Restrict component submenu items using ACL ?

Post by Webdongle » Sat Apr 23, 2022 7:44 pm

1. Create a new user group add the relevant permissions and select it in the 'Special' view access level
2. In each Super Users account select the new user group
3. Create a view access level and the new group in it
4. Set the view level of the (relevant) menu items to the new access level
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".


Locked

Return to “Access Control List (ACL) in Joomla! 3.x”