1

Anyone know of such a module?

Basically I want to dynamically load the users in certain usergroups inside an article with the loadmodule option.

Mind gem
  • 134
  • 1
  • 10

2 Answers2

1

Ended up building myself.

modfile:

<?php

defined('_JEXEC') or die;

// Include the latest functions only once
require_once __DIR__ . '/helper.php';

$shownumber         = $params->get('shownumber', 10);
$groupnumber        = $params->get('group', 4);

$names              = ModUsersUsergroupHelper::getUsers($params);

$moduleclass_sfx    = htmlspecialchars($params->get('moduleclass_sfx'), ENT_COMPAT, 'UTF-8');

require JModuleHelper::getLayoutPath('mod_users_usergroup', $params->get('layout', 'default'));

helper:

<?php

defined('_JEXEC') or die;

/**
 * Helper for mod_users_usergroup
 *
 * @package     Joomla.Site
 * @subpackage  mod_users_usergroup
 *
 * @since       1.6
 */

class ModUsersUsergroupHelper
{

/**
 * Get users in a certain usergroup
 *
 * @param   \Joomla\Registry\Registry  $params  module parameters
 *
 * @return  array  The array of users
 *
 * @since   1.6
 */

public static function getUsers($params)
{

    $db         = JFactory::getDbo();

    $groupId    = $params->get('group', 2);

    $query      = $db->getQuery(true)
        ->select($db->quoteName(array('u.id', 'u.name', 'u.username', 'u.registerDate')))
        ->order($db->quoteName('u.registerDate') . ' DESC')
        ->from('#__users AS u')
        ->join('INNER', '#__user_usergroup_map AS ugm ON ugm.user_id = u.id')
        ->where('ugm.group_id =' . $db->quote($groupId));

    $db->setQuery($query, 0, $params->get('shownumber'));

    try
    {

        return (array) $db->loadObjectList();

    }

    catch (RuntimeException $e)
    {

        JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');

        return array();

            }

        }

}
Mind gem
  • 134
  • 1
  • 10
0

I am not aware of such an extension but you could include some code in a Custom HTML module using Sourcerer or similar to achieve the desired result.

The Custom HTML module can then be displayed in an article using loadmodule.

For some example code see: https://stackoverflow.com/a/20743966

Community
  • 1
  • 1
Neil Robertson
  • 3,295
  • 3
  • 28
  • 49