News:

Join the Facebook Fan Page.

Main Menu

SMF to PHP

Started by demonxanx, July 27, 2015, 04:33:40 PM

Previous topic - Next topic

demonxanx

So in my previous thread which can be found here: Previous Thread
I asked how I can grab the group id and display the users information within that group on a php page. This did help me however I'm still left in the blank, I'm quite new to SMF.

So now let me show you what I want to achieve.
Over here I've got a link to my website's staff list which is written in html and css creating a very nice looking staff list: hxxp:moonshade.net/stafflist [nonactive]
I was wondering how I can both grab users id's and groups id's and convert them into the staff list shown above.
I want to have it so that when I select multiple group id's, I want it to create a new div and show the information of users within that specific group.
The thing is I don't want all the information to show up, I only want certain information to show up such as their names, their avatars, link to their profiles and perhaps even their custom fields.

Pretty sure this shouldn't be hard but I just cannot figure it out by myself.
To help you guys out I've also pasted in the html and css codes down below so that you can look through it and help me integrate it into the code.

Thank you in advance for the help. Hopefully this is enough information for you guys to help me figure this out.

pastebin.com/qR18eRjB - HTML Code
pastebin.com/NAxyxfgv - CSS Code

Kindred

when you use an SSI function, you can output as an array instead of a block of pre-made code...

in which case, you can then parse out the contents of the array in any manner you desire, including or not including any part of the data
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Gluz

I have something like that, a page with the Staff in a custom template.

$staff = ssi_fetchGroupMembers(15, 'array');
echo 'Staff: <br/>';
foreach ($staff as $a) {
    echo '<div class="staff"><a href="',$a['href'],'">',$a['name'],'<br/>',$a['avatar']['image'],'</a><br/><a href="',$a['online']['href'],'">Send PM</a><br/>',(!empty($a['options']['cust_textor'])?$a['options']['cust_textor']:''),'</div>';
}


Note that ssi_fetchGroupMembers() function expect only one 'int' and optionally the output method(omit the seccond parameter or 'echo' for the default method, something else for array).


So, you have to construct basically the same HTML that you have, but instead of repeat the staff divs you need to use a foreach loop through the staff array, and use the array data to populate the template you made.


To see the info you need (like the custom profile fields for Steam profile and the other) you can put this at the end of the php file (change the 1 to the ID of one member in that group).
echo '<pre>';
print_r($staff[1]);
echo '</pre>';

Kindred

Gluz,

ssi_fetchGroupMembers can accept an ARRAY of INTs - not just one.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Gluz

#4
From SSI.php:
// Get all members of a group.
function ssi_fetchGroupMembers($group_id = null, $output_method = 'echo')
{
if ($group_id === null)
return;

$query_where = '
id_group = {int:id_group}
OR id_post_group = {int:id_group}
OR FIND_IN_SET({int:id_group}, additional_groups) != 0';

$query_where_params = array(
'id_group' => $group_id,
);

return ssi_queryMembers($query_where, $query_where_params, '', 'real_name', $output_method);
}


I don't see any way to use an array there, it expect only one INT.



EDIT:
Error log when I put an array of INTs for that function:
Wrong value type sent to the database. Integer expected. (id_group)
Function: ssi_fetchGroupMembers
File: /homepages/32/d543775650/htdocs/SSI.php

Advertisement: