Hi,
I need to know how to set up the ssi in a PHPBOX so that I show all the members part of group ID 36, not only the ones on-line
Right now I have this:
require("/home/web/public_html/SSI.php");
ssi_membergroup($groupid = 36, $additional = 0, $sort = 1, $sortorder = 1, $output_method = 'echo');
But this does not work. It does not show ALL the members of that group which there is 12... it only shows 4 of them...?!?
Please help, Thanks
Where did you get the function? I don't find it in my SSI.php.
Maybe you could paste the function here so we're all working with the same code to start with.
it's part of a mod ssi function from SMF.
the code in SSI_membergroup.xml
<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<id>SleePy:SSI_Membergroup</id>
<version>1.0</version>
<file name="$boarddir/SSI.php">
<operation>
<search position="end"></search>
<add><![CDATA[
// Show From all from a member group. Great for Rosters.
function ssi_membergroup($groupid = 1, $additional = 0, $sort = 1, $sortorder = 1, $output_method = 'echo')
{
global $db_prefix, $user_info, $scripturl, $modSettings, $txt, $sc;
//-- $mgroup = Group Number
//-- $Additional = Search Additional Groups as well
//-- $sort = How to sort the names. ID Number(2) or realname(1 default).
//-- $sortorder = Sort ASC or DESC
//Lets get some checks done for the sake of the script not returning errors
//if the groupids are array we need to make them valid.
if(is_array($groupid))
$groupid = array_map('intval',$groupid);
//Well the groupid is a single id.. lets make it valid..
if(!is_array($groupid))
$groupid = (int) $groupid;
//Either its off or its on.. Should also stop use of array..
if(($additional !=0 && $additional !=1) || ($sort !=2 && $sort !=1) || ($sortorder !=2 && $sortorder !=1))
fatal_error('Invalid Input for this ssi_function');
//We shouldn't be getting Group 0. Fix it by Showing Admin Group..
if($groupid == 0)
$groupid = 1;
//Set our output to something its better than nothing.
$membergroup = array();
//Find out if our groups we are looking at is in an array or not..
if(is_array($groupid))
{
//Array has multiple groups so if we want to search additional as well we have to loop it.
if(isset($additional) && $additional != 0)
{
//lets just clear additional instead of a new variable.
$additional = '';
foreach($groupid as $add)
$additional .= '
OR FIND_IN_SET('.$add.', additionalGroups)';
}
$request = db_query("
SELECT ID_MEMBER, realname, ID_GROUP
FROM {$db_prefix}members
WHERE ID_GROUP IN (" . implode(', ',$groupid) . ")".$additional."
ORDER BY '".($sort == 2 ? 'ID_MEMBER' : 'realname')."' ".($sortorder == 2 ? 'DESC' : 'ASC')."", __FILE__, __LINE__);
}
else
$request = db_query("
SELECT ID_MEMBER, realname, ID_GROUP
FROM {$db_prefix}members
WHERE ID_GROUP = " . $groupid . ($additional == 1 ? "
OR FIND_IN_SET(" . $groupid . ", additionalGroups)" : "")."
ORDER BY '".($sort == 2 ? 'ID_MEMBER' : 'realname')."' ".($sortorder == 2 ? 'DESC' : 'ASC')."", __FILE__, __LINE__);
//We got the query. Now lets get it into a nice little array..
while ($row = mysql_fetch_assoc($request))
$membergroup[] = array(
'id' => $row['ID_MEMBER'],
'name' => $row['realname']
);
mysql_free_result($request);
//If they dont want to echo.. So lets give it to them..
if ($output_method != 'echo')
return $membergroup;
//Well they want it echo so lets echo...
foreach ($membergroup as $mem)
echo '
<a href="'.$scripturl.'?action=profile;u='.$mem['id'].'" class="ssi_membergroup" id="ssi_member_'.$mem['id'].'">'.$mem['name'].'</a><br/>';
}
]]></add>
</operation>
</file>
</modification>
It might have been a bit better if you would have just posted the code from your SSI.php file. I figured it out, though.
I don't know why it wouldn't print out all of them. The code looks like it should work.
It might be easier if you used code to just display what you want.
global $db_prefix, $scripturl;
$request = db_query("
SELECT ID_MEMBER, realname
FROM {$db_prefix}members
WHERE ID_GROUP = 36
ORDER BY realname", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
echo '
<a href="'.$scripturl.'?action=profile;u='.$row['ID_MEMBER'].'">'.$row['realname'].'</a><br/>';
For some strange reason, your code also does not work.... only 2
Is your group 36 a post-based group or one that's assigned to members? If it's post-based, I don't think you're going to be able to get it at all.
If it's an assigned group, I've not got a clue why it wouldn't work.
You need to set "additional" value to 1, not 0, so it searches the members which have that group as additional - not primary. Only 4 prob have it as primary by the sound of it.
EDIT: for the first function displayed.
fixed... SMF was saying there was 12 members in the group same as if you selected the membergroup "2008 Supporters) you would see all 12 members, yet when I went to each of the members profiles and look at the account related settings for Primary member group, only the 2 members would be in the "2008 Supporters" group everyone else (the 10 other) had Primary group as "site supporter" but secondary group was "2008 supporter".
So is there 2 types of groups?
LOL !
I was writting the above message as you replied Bloc !
Thanks !
took you 35 minutes to post after Bloc? lol
Think this is solved now ?
I mark it as solved.
Also as a side note, when ever another mod is used then the functions with in TP, please consult the mod author in the first place to sort out how that mod works :)
Quote from: JPDeni on March 19, 2008, 04:57:06 PM
global $db_prefix, $scripturl;
$request = db_query("
SELECT ID_MEMBER, realname
FROM {$db_prefix}members
WHERE ID_GROUP = 36
ORDER BY realname", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
echo '
<a href="'.$scripturl.'?action=profile;u='.$row['ID_MEMBER'].'">'.$row['realname'].'</a><br/>';
JP,
What would I need to put in a file.php to get this working ?
It's calling for settings fro the DB so I guess it needs a require statement, but not sure how to do that.... and also need the <PHP? and ?> to work right?
What if I wanted to put this in a script box instead...? How would I do this?
QuoteWhat would I need to put in a file.php to get this working ?
I don't know. I work within TP blocks. I've pretty much forgotten how to work outside of them.
Quoteand also need the <PHP? and ?> to work right?
Yes
QuoteWhat if I wanted to put this in a script box instead...? How would I do this?
It would go into a php block. Since you have that mod installed, you can just use
ssi_membergroup($groupid = 36, $additional = 1, $sort = 1, $sortorder = 1, $output_method = 'echo');
G6, when I started answering this, I didn't know it was a mod. By the time I learned it was, I felt I was already committed. (Maybe I should be committed, but that's a different story! :uglystupid2: )
The PS was not ment to you JP, it was ment to npereira
To little info given on the first post so you couldent know what it was. And as always the posting guides tell our members what to do to help us help them. And we all know that the people that makes the mods available, have the best knowlage on how to make them work in diffrent ways.
So the point was not to you Girl :D