Page 1 of 1

HOWTO? Acquiring a list of all "editors" or higher? [SOLVED]

Posted: Fri Dec 28, 2007 11:31 am
by jurgentje
Hi,

I'm practicing on writing my first Joomla (1.5) component. For this, I'd like to pull in a list of all members that have the level "Editor" (GID 19) or higher...

I notice the Content component actually pulls in a full list of all members... but I can't find the exact spot where this happens when looking into the code.

My first idea would be something like this:

Code: Select all

$db =& JFactory::getDBO();
$sql = "SELECT * FROM #__users WHERE gid>18";
$db->setQuery($query);
$rows = $db->loadObjectList();


Is this the right way to go? Or is there a better way?

Re: HOWTO? Acquiring a list of all "editors" or higher?

Posted: Sat Jan 05, 2008 11:23 pm
by dan1dyoung
Looks OK as long as there become no custom groups in between, just change your code as below

From:
$sql = "SELECT * FROM #__users WHERE gid>18";
$db->setQuery($query);

To:
$query = "SELECT * FROM #__users WHERE gid>18";
$db->setQuery($query);

Thanks

Dan

Re: HOWTO? Acquiring a list of all "editors" or higher?

Posted: Sun Jan 06, 2008 7:15 am
by jurgentje
lol!

Yeah, that was an obvious one! (I didn't even have that mistake in my real code)

Thanks for confirming this!

Re: HOWTO? Acquiring a list of all "editors" or higher? [SOLVED]

Posted: Sun Jan 06, 2008 10:22 pm
by Pentacle
If you want to create a select list of editors, take a look at JHTMLList class in libraries/joomla/html/html/list.php. It's much easier to use and also forward-compatible. Example code:

Code: Select all

<?php echo JHTML::_('list.users', 'added_by', 1, 0, NULL, 'name', 1); ?>


P.S. You should add 'AND block = 0' to the code that dan1dyoung suggested.