Customization > Blocks and Modifications

SMF Social Groups Block

(1/3) > >>

NIBOGO:
This is a block to show the recent groups in the SMF Social Groups Mod:

Create a new php block and add this content:

SMF 2.0


--- Code: ---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);

--- End code ---

SMF 1.1.X:


--- Code: ---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);
--- End code ---

Best Regards

Nathaniel:
Moved to the Blocks and Modifications board.

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

NIBOGO:

--- Quote from: 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.

--- End quote ---

Thanks for remind me, already added to the topic title

ccbtimewiz:
For SMF 1.1...


--- Code: ---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);
--- End code ---

NIBOGO:

--- Quote from: ccbtimewiz on March 12, 2010, 12:50:57 AM ---For SMF 1.1...


--- Code: ---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);
--- End code ---


--- End quote ---

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


--- Code: ---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);
--- End code ---

Thanks ccbtimewiz :)

Navigation

[0] Message Index

[#] Next page

Go to full version