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

Discussion and education for beginner / novice programmers interested in embarking on the development process to take advantage of the extensible nature of the Joomla! CMS.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Forum rules
Post Reply
User avatar
jurgentje
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Wed Mar 15, 2006 7:32 am
Location: Vilvoorde

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

Post by jurgentje » Fri Dec 28, 2007 11:31 am

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?
Last edited by jurgentje on Sun Jan 06, 2008 7:16 am, edited 1 time in total.

User avatar
dan1dyoung
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Fri Dec 09, 2005 6:18 pm
Location: England
Contact:

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

Post by dan1dyoung » Sat Jan 05, 2008 11:23 pm

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

User avatar
jurgentje
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Wed Mar 15, 2006 7:32 am
Location: Vilvoorde

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

Post by jurgentje » Sun Jan 06, 2008 7:15 am

lol!

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

Thanks for confirming this!

User avatar
Pentacle
Joomla! Intern
Joomla! Intern
Posts: 61
Joined: Wed Oct 25, 2006 12:34 pm
Location: Turkey

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

Post by Pentacle » Sun Jan 06, 2008 10:22 pm

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.
My Joomla! 1.5 extensions - http://joomla.ercan.us
Progress is made by lazy men looking for easier ways to do things.


Post Reply