2006-07-16, 03:31 PM
2006-07-16, 05:24 PM
Since I wanted this list in multiple places (Who's Online block on the index page, Member List, etc), I made a function. $open get prepended to every formatted name, while $close gets appended. The string {gid} will be translated to the actual group id, so you could include URLs (for example, link to a modified memberlist.php which only lists users who belong to a certain group).
You include the following code on each page you want the legend to show up (not: I should allow the word Legend to be translated):
Then I added the variable $groups_legend to the template.
function formattedgrouparray( $open="", $close="")
{
global $db, $mybb, $settings, $lang;
$query = $db->query("SELECT * FROM " . TABLE_PREFIX . "usergroups WHERE gid!=1 ORDER BY isbannedgroup ASC, showforumteam DESC, issupermod DESC, usertitle");
$groups = array();
while ( $group = $db->fetch_array($query) )
{
$my_open = str_replace( array("{gid}"), array($group['gid']), $open);
$my_close = str_replace( array("{gid}"), array($group['gid']), $close);
$title = ($group['usertitle']) ? $group['usertitle'] : $group['title'];
$groups[] = $my_open . formatname( $title, $group['gid'] ) . $my_close;
}
return $groups;
}
You include the following code on each page you want the legend to show up (not: I should allow the word Legend to be translated):
$groups = formattedgrouparray();
$groups_legend = "<b>Legend</b>: " . join(" | ", $groups);
Then I added the variable $groups_legend to the template.
2006-07-16, 06:16 PM
Man thnks a lot...