SimplePortal

Customization => Blocks and Modifications => Topic started by: NIBOGO on March 09, 2010, 09:36:05 PM

Title: SMF Social Groups Block
Post by: NIBOGO on March 09, 2010, 09:36:05 PM
This is a block to show the recent groups in the SMF Social Groups Mod (http://www.smfpacks.com/index.php?action=page;sa=sg):

Create a new php block and add this content:

SMF 2.0

Code: [Select]
global $smcFunc, $scripturl;

 echo'Recent Groups:<br />';

$dbresult = $smcFunc['db_query']('', '
   SELECT id_group, group_name, image
   FROM {db_prefix}social_groups
   ORDER BY id_group DESC
   LIMIT 5'); 
while ($row = $smcFunc['db_fetch_assoc']($dbresult))
{
   echo'<a href="'.$scripturl.'?action=sgroups;sa=view;id='.$row['id_group'].'"><img src="'.$row['image'].'" alt="'.$row['group_name'].'" /></a>';
}
$smcFunc['db_free_result']($dbresult);

SMF 1.1.X:

Code: [Select]
global $db_prefix, $scripturl;

 echo 'Recent Groups:<br />';

$dbresult = db_query('
   SELECT ID_GROUP, groupName, image
   FROM {$db_prefix}social_groups
   ORDER BY ID_GROUP DESC
   LIMIT 5', __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($dbresult))
{
   echo'<a href="'.$scripturl.'?action=sgroups;sa=view;id='.$row['ID_GROUP'].'"><img src="'.$row['image'].'" alt="'.$row['groupName'].'" /></a>';
}
mysql_free_result($dbresult);

Best Regards
Title: Re: SMF Social Groups Block
Post by: Nathaniel on March 10, 2010, 01:26:46 AM
Moved to the Blocks and Modifications board.

Note for all, this block will only work for SMF 2.
Title: Re: SMF Social Groups Block - Only for SMF 2.0
Post by: NIBOGO on March 11, 2010, 09:09:48 PM
Moved to the Blocks and Modifications board.

Note for all, this block will only work for SMF 2.

Thanks for remind me, already added to the topic title
Title: Re: SMF Social Groups Block - Only for SMF 2.0
Post by: ccbtimewiz on March 12, 2010, 12:50:57 AM
For SMF 1.1...

Code: [Select]
global $db_prefix, $scripturl;

 echo 'Recent Groups:<br />';

$dbresult = db_query('
   SELECT ID_GROUP, groupName, image
   FROM {$db_prefix}social_groups
   ORDER BY ID_GROUP DESC
   LIMIT 5', __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($members_result))
{
   echo'<a href="'.$scripturl.'?action=sgroups;sa=view;id='.$row['ID_GROUP'].'"><img src="'.$row['image'].'" alt="'.$row['groupName'].'" /></a>';
}
mysql_free_result($dbresult);
Title: Re: SMF Social Groups Block - Only for SMF 2.0
Post by: NIBOGO on March 12, 2010, 02:41:16 PM
For SMF 1.1...

Code: [Select]
global $db_prefix, $scripturl;

 echo 'Recent Groups:<br />';

$dbresult = db_query('
   SELECT ID_GROUP, groupName, image
   FROM {$db_prefix}social_groups
   ORDER BY ID_GROUP DESC
   LIMIT 5', __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($members_result))
{
   echo'<a href="'.$scripturl.'?action=sgroups;sa=view;id='.$row['ID_GROUP'].'"><img src="'.$row['image'].'" alt="'.$row['groupName'].'" /></a>';
}
mysql_free_result($dbresult);


There is a error in that code that I already fix in the SMF 2.0 version, here is the patched version:

Code: [Select]
global $db_prefix, $scripturl;

 echo 'Recent Groups:<br />';

$dbresult = db_query('
   SELECT ID_GROUP, groupName, image
   FROM {$db_prefix}social_groups
   ORDER BY ID_GROUP DESC
   LIMIT 5', __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($dbresult))
{
   echo'<a href="'.$scripturl.'?action=sgroups;sa=view;id='.$row['ID_GROUP'].'"><img src="'.$row['image'].'" alt="'.$row['groupName'].'" /></a>';
}
mysql_free_result($dbresult);

Thanks ccbtimewiz :)
Title: Re: SMF Social Groups Block
Post by: ccbtimewiz on March 12, 2010, 11:25:36 PM
You're welcome.
Title: Re: SMF Social Groups Block
Post by: Mick. on March 29, 2010, 07:22:21 PM
Can the group name be added above the group image?  :|
Title: Re: SMF Social Groups Block
Post by: NIBOGO on April 02, 2010, 11:23:41 PM
Can the group name be added above the group image?  :|

Sure:

Code: [Select]
global $smcFunc,   $scripturl;

 echo'Recent Groups:<br />';

$dbresult =   $smcFunc['db_query']('', '
   SELECT id_group, group_name, image
     FROM {db_prefix}social_groups
   ORDER BY id_group DESC
   LIMIT   5'); 
while ($row = $smcFunc['db_fetch_assoc']($dbresult))
{
     echo'<a   href="'.$scripturl.'?action=sgroups;sa=view;id='.$row['id_group'].'"><img   src="'.$row['image'].'" alt="'.$row['group_name'].'" /><br />'.$row['group_name'].'</a>';
}
$smcFunc['db_free_result']($dbresult);

You can use some tags to center the text like <div align="center">'.$row['group_name'].'</div>
Title: Re: SMF Social Groups Block
Post by: EvilGeneral on May 04, 2011, 04:38:30 PM
Isn't work for me. =[
The image path is wrong.

PS: Most difficult thing in this forum is type the correct captcha. lol
Title: Re: SMF Social Groups Block
Post by: angeljs on June 18, 2015, 10:09:01 AM
The image link isn't working, how can this be fixed?
Title: Re: SMF Social Groups Block
Post by: angeljs on June 18, 2015, 10:28:20 AM
Okay, I managed to fix the broken image link. Simply replace this piece of code:

Code: [Select]
<img src="'.$row['image'].'" alt="'.$row['group_name'].'" />
With this:

Code: [Select]
<img src="http://www.fullurltoyourboard.com/sogroups/'.$row['image'].'" alt="'.$row['group_name'].'" />
Replace the link with the full link to your forum installation and it should work. I'm not a coder, so this is only a quick fix, if anyone has a better idea it would be appreciated.  :D
SimplePortal 2.3.8 © 2008-2024, SimplePortal