phpBB2 style Group Legend display

Post Reply
User avatar
kinerity
Administrator
Administrator
Posts: 4
Joined: Fri Jul 26, 2019 7:47 pm
Name: Kailey Truscott

phpBB2 style Group Legend display

Post by kinerity » Tue Aug 13, 2019 7:05 pm

Taken from an idea posted @ phpBB.com, this snippet will modify the group legend on the index to look like it did back on phpBB2.

OPEN: /index.php

FIND:

Code: Select all

$legend = array();
while ($row = $db->sql_fetchrow($result))
{
	$colour_text = ($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . '"' : '';
	$group_name = $group_helper->get_name($row['group_name']);

	if ($row['group_name'] == 'BOTS' || ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')))
	{
		$legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
	}
	else
	{
		$legend[] = '<a' . $colour_text . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $row['group_id']) . '">' . $group_name . '</a>';
	}
}
$db->sql_freeresult($result);

$legend = implode($user->lang['COMMA_SEPARATOR'], $legend);
REPLACE WITH:

Code: Select all

$legend = array();
while ($row = $db->sql_fetchrow($result))
{
	$colour_text = ($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . '"' : '';
	$group_name = $group_helper->get_name($row['group_name']);

	if ($row['group_name'] == 'BOTS' || ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')))
	{
		$legend[] = '[ <span' . $colour_text . '>' . $group_name . '</span> ]';
	}
	else
	{
		$legend[] = '[ <a' . $colour_text . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $row['group_id']) . '">' . $group_name . '</a> ]';
	}
}
$db->sql_freeresult($result);

$legend = implode(' ', $legend);
You can easily play about with the separators. The brackets were added to $legend[] and the spacing is done in $legend = implode(' ', $legend); (that's where the comma was removed).

Post Reply