Get module list Topic is solved

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
alve89
Joomla! Apprentice
Joomla! Apprentice
Posts: 40
Joined: Sun Jul 01, 2012 10:45 pm

Get module list

Post by alve89 » Wed Dec 08, 2021 7:08 am

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

Code: Select all

jimport( 'joomla.application.module.helper' );
$modulesList = JModuleHelper::getModuleList();
but this only returns the backend modules, not the listed frontend-modules in com_modules.

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17443
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Get module list

Post by toivo » Wed Dec 08, 2021 9:03 am

If just a simple list of the front end modules is required, get it through a database query, for example:

Code: Select all

SELECT * FROM joomlatest.wlreu_modules
WHERE client_id = 0
The modules can also be listed by the viewing access level, for example:

Code: Select all

SELECT v.title AS ViewLevel, m.title AS Module FROM wlreu_modules m
LEFT JOIN wlreu_viewlevels v ON m.access = v.id
WHERE (m.client_id = 0) AND (m.published = 1)
ORDER BY v.title, m.title
Toivo Talikka, Global Moderator

alve89
Joomla! Apprentice
Joomla! Apprentice
Posts: 40
Joined: Sun Jul 01, 2012 10:45 pm

Re: Get module list

Post by alve89 » Wed Dec 08, 2021 9:10 am

Thank you for your answer. A DB query doesn't solve the real problem: Not to display unallowed modules. I need to access the already loaded modules (in com_modules) and edit this list.

alve89
Joomla! Apprentice
Joomla! Apprentice
Posts: 40
Joined: Sun Jul 01, 2012 10:45 pm

Re: Get module list

Post by alve89 » Wed Dec 08, 2021 12:19 pm

Problem solved:
  1. Copy the template file you want to override from (in my case) /administrator/components/com_modules/views/modules/tmpl/default.php to /administrator/templates/YOURADMINTEMPLATE/html/com_modules/modules/default.php
  2. Edit it as you want


Locked

Return to “Joomla! 3.x Coding”