News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

SSI MemberGroup

Started by SleePy, November 07, 2006, 10:48:21 AM

Previous topic - Next topic

SleePy

Well that one would use the second one since it isn't an array..
$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__);


It functions properly as I tested this throughly on my site and currently use a similar function on one of my user groups.

Are you sure your membergroup ID is 30 and not your member ID?

Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Saku

yes I'm sure, my member ID = 1 as I'm the forum admin

SleePy

Well it should be working. I don't have a group id of 30 but I got one with 16 and 45 and they both work fine using that method.
Did you include SSI.php before that? with it pointed correctly to the path on your forums? is this ina  php file?
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Saku


NiteCloak

#24
I'm totally confused by this SSI stuff.  Here is a mod, which clearly does something I actually need (i.e. to be able to generate a roster of my members and then output it to a page), but there are no instructions for a layman like me about how to use it in a manner that can be understood.

It gets frustrating not knowing how to code yet have a need which appears to be being met by something someone has written yet there's little or no effort to bridge the gap between the mod in question and an explanation for a layman about how to use it.

That's what makes the mods/packages that integrate in to the forum admin panel so great.  From a technical user perspective, its easy to get to grips with a new mod when it integrates in this way.  Sadly, when it means digging in to code, writing code or whole pages, then I for one am lost.

I've spent ages studying your code snippets and trying to understand what the heck an array is, let alone the code.  I cannot find any references to the membergroup ID numbers?  I looked all through my forum admin panel and couldn't find any.  Where are they found?

My forum is simple. I have two administrators and everyone else is in whatever member group it is that people get sent to when they register.

All I want to do is use your code to output the members of that registered group to a page everyone can view.  Or better yet, in a topic I can post on our announcement forum. Thats it. 

Help!

~ ~ ~
Avatar Packs by NiteCloak:
Super Heroes : Status : Download
Sci-Fi & Fantasy Fiction : Status : Download
Military Assault Weapons : Status : Download
Ancient Symbolism : Status : Download
~~~
One good turn gets all the sheets

SleePy

NiteCloak,

Sorry for the delay. I lost my notifications for some reason on my mods so I wasn't notified that somebody had replied.

My mod uses SSI. There is a SSI readme  for SMF in general (doesn't cover my mod)
http://www.simplemachines.org/community/index.php?topic=14906.0

But reading those will help you understand how SSI words and how to generate the information you need.
You need to know a bit of PHP at least to use SSI or how to use SHTML (with limited functionality though on most functions.

I posted an example php script so that may help you how to do it.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

KnightRobby

I know this is probably very easy for you guys to understand, but it says that I am to use the following code for the MOD (MOD HERE):

ssi_membergroup($groupid = 1, $additional = 0, $sort = 1, $sortorder = 1, $output_method = 'echo')


ssi_membergroup(2, 1);


$groups = array (1,2);
ssi_membergroup($groups, 1);


$groups = array (1,2);
$mygroup = ssi_membergroup($groups, 1, 1, 1, 'array');
foreach($mygroup as $mem)
echo '<a href="'.$scripturl.'?action=profile;u='.$mem['id'].'" class="ssi_membergroup" id="ssi_member_'.$mem['id'].'">'.$mem['name'].'</a><br/>'


I am so confused and was REALLY looking forward to using this this MOD, thinking that it would be setup already.  So what do I do with the code and where do I put it?  I know it might be such a simple question to you guys, but I am lost.  LOL :)

Thanks again everyone,
Robby :)
WebQuad Gaming Community
Sections: Gears of War, Call of Duty 3, and Our Awesome Gaming Community Forums.

SleePy

It goes in Your php pages that you have SSI.php included

Read this for more info on SSI.php
[README] SSI FAQ's

Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

KnightRobby

I did read the readme SSI FAQ and I am a little confused.  I just need to know the exact code to input into my .php page.  I know that much, but I don't exactly know how the code fits together.  Sorry for all of the questions and thanks in advance!

Robby :)
WebQuad Gaming Community
Sections: Gears of War, Call of Duty 3, and Our Awesome Gaming Community Forums.

SleePy

Well first you need to make sure SSI.php is included.

Then just use one of the examples I posted to work it.
The first example is the most basic. The second one is showing multiple groups and the third one shows just about everything you can do with the function.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Davy-D

Hey SleePy,

great Mod, really. It's exactly what I was looking for.

I have a small suggestion for the next version.
Please add a function to convert German "Umlauts" to the appropriate HTML character. The following code most probably is not the smoothest, but it worked for me:

In SSI.php, add before "function ssi_membergroup(" ...
function Asc2HTML($string) {
$ascii=array("Ä","Ö","Ü","ä","ö","ü","ß","'");
$html=array("&Auml;","&Ouml;","&Uuml;","&auml;","&ouml;","&uuml;","&szlig;",""");
$string=str_replace($ascii,$html,$string);
return $string;
}


... and replace the call ...

<a href="'.$scripturl.'?action=profile;u='.$mem['id'].'" class="ssi_membergroup" id="ssi_member_'.$mem['id'].'">'.$mem['name'].'</a><br/>'

... by ...

<a href="'.$scripturl.'?action=profile;u='.$mem['id'].'" class="ssi_membergroup" id="ssi_member_'.$mem['id'].'">'.Asc2HTML($mem['name']).'</a><br/>';

... that's it.

Best regards,
Davy-D

SleePy

#31
I wasn't aware that this was being passed incorrectly.
Do other SSI functions do this correctly? I am sure that SMF should be handling all  of the internals work for me really and I shouldn't need to do that.
But I will note it anyways.

Though what is the single quote to double quote? (As well since you didn't escape it there would be a parse error).
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

vsobral

Hi great mod!

I'm having a problem with javascript and this mod, could you help me please

the code i'm trying is this one but nothing happens within the <div> when the mouse is pressed

Thanks


<table width="20%" border="0" cellspacing="0" cellpadding="4" align="left" class="tborder">

<tr>




<td class="windowbg" width="20%" align="left"> <input type="button"  value="Administradores" onclick=';
echo"'";
echo '
document.getElementById("ct").innerHTML = "'.ssi_membergroup($groupid = 1, $additional = 1, $sort = 1, $sortorder = 1, $output_method = 'echo').'"';
echo "'";
echo '
/> <br />
        </td>  </tr></table>

SleePy

You may need to have it return as an array instead and set it as a variable.
Array might be easier as well to configure it for how you are doing this.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

vsobral

#34
I'm sorry but how could I do that ?

I've tried

document.getElementById("ct").innerHTML = "'.$groups[1]['output'].'"';

The result is just "Array"

but if I put

document.getElementById("ct").innerHTML = "'.$groups[1]['name'].'"';

it gives the group name

Thanks

SleePy

How you are you doing the code exactly?
Is those variables even setup somewhere?

NO where in the output of the mod does it actually set the group name, the only output is the id and member name.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

vsobral

I've copy the example you have put before

$groups = array (
      1 => array (
            'name' => 'Administradores',
            'output' => ssi_membergroup(array(1),1,1,1,"array"),
            ),....

vsobral

I'm getting nuts trying to solve this here is my entire code:

<?php




if (!defined('SMF'))
   die('Hacking attempt...');

require(dirname(__FILE__) . '/../SSI.php');

function template_main()
{
global $context, $settings, $options, $txt, $scripturl;


      $groups = array (
      1 => array (
            'name' => 'Administradores',
            'output' => ssi_membergroup((1),1,1,1,"array"),
            ),
      2 => array (
            'name' => 'NbS',
            'output' => ssi_membergroup(array(92,91),1,1,1,"array"),
            ),
      3 => array (
            'name' => 'RoKs',
            'output' => ssi_membergroup(62,1,1,1,"array"),
            ),
      4 => array (
         'name' => 'WTF',
            'output' => ssi_membergroup(array(57,15),1,1,1,"array"),
            ),
      5 => array (
            'name' => 'KaG Community - All Girls',
            'output' => ssi_membergroup(array(11,56),1,1,1,"array"),
            ),
      6 => array (
            'name' => 'Tribal',
            'output' => ssi_membergroup(16, 1,1,1,"array"),
            ),
      );


   
      $info = $groups[1]['output'];
   
      
      
   

echo '


<table width="100%" border="0" cellspacing="0" cellpadding="3" >
<tr>
<td>', theme_linktree(), '</td>
</tr>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="4" align="center" class="tborder">
<tr class="titlebg" >
<td align="center" width="100%">Staff do P@P</td>
</tr></table>
<table width="20%" border="0" cellspacing="0" cellpadding="4" align="left" class="tborder">

<tr>


<td class="windowbg" width="20%" align="left"> <input type="button"  value="Administradores" onclick=';
echo"'";
echo '
document.getElementById("ct").innerHTML = "'.$info.'"';

echo "'";
echo '
/> <br />
        </td>  </tr></table>
            
        <table width="40%" border="0" cellspacing="0" cellpadding="4" align="center">
       
        <tr>
        ';
         
echo '
</tr>
</table>

<div id="ct">oláaaaaaaaaaaa</div>
';
      
}





?>

SleePy

The issue is you are using SSI withen SMF.

// Don't do anything if SMF is already loaded.
if (defined('SMF'))
return true;


This code prevents this from happening.

SSI is designed for using SMF outside of SMF itself.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

vsobral

Sorry but if I put that code I can´t access the ssi functions

Advertisement: