Get displayed modules list in com_modules

16 views
Skip to first unread message

sig...@die-herzogs.com

unread,
Dec 8, 2021, 2:32:05 AM12/8/21
to Joomla! General Development
Hi all,

I'm about to write a plugin that filters the modules depending on a user's permission to edit specific frontend-modules (in backend!). So: User A has the permission to edit moduleA, moduleC, and moduleD, but not moduleB.

Since I have over 200 modules I need to filter the displayed list to show the users only the allowed modules.

How can I access the available modules and edit this list in order to remove all the modules from being displayed which are not editable by the current logged in user?

I thought of

jimport( 'joomla.application.module.helper' ); $modulesList = JModuleHelper::getModuleList();

but this only returns the backend modules, not the listed frontend-modules in com_modules.

Viper

unread,
Dec 8, 2021, 4:24:02 AM12/8/21
to Joomla! General Development
getModuleList() return modules based on application type. For site(if you call this on frontend) it will return modules from frontend, and for backend - only backend modules. You cannot change this.
Just overload this method with you own implementation or make a new class with method.

sig...@die-herzogs.com

unread,
Dec 8, 2021, 5:44:14 AM12/8/21
to Joomla! General Development
I thought that, it was just the only thing I found.

Isn't there another way than overloading to get / access the displayed list items (placed in /administrator/components/com_modules/views/modules) and change this item list? It doesn't help to just get this modules list, I need to edit it - so I need to access the exact one which is getting rendered (in my opinion).

sig...@die-herzogs.com

unread,
Dec 8, 2021, 7:21:02 AM12/8/21
to Joomla! General Development
Problem solved. It's just overriding the view file (/administrator/components/com_modules/views/modules/tmpl/default.php) in /administrator/templates/<ADMINTEMPLATE>/com_modules/modules/default.php.
Reply all
Reply to author
Forward
0 new messages