News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

Group id with group name

Started by Joker™, January 13, 2011, 09:50:14 AM

Previous topic - Next topic

Joker™

Only for SMF 2x

I've seen a lot of people asking that how can we know id of a member group. It is shown in the url when someone is modifying a member group, but it's bit difficult to this out to everyone specially new users. Just make the below given modifications and your group id will be shown next to the group name in

Administration Center » Membergroups

There are 2 styles to achieve this modification

This code will give you the effect shown in Screen Shot 1

Open Sources\ManageMembergroups.php (Make backup if file before editing it)

Find:
// Since the moderator group has no explicit members, no link is needed.
if ($rowData[\'id_group\'] == 3)
$group_name = $rowData[\'group_name\'];
else
{
$color_style = empty($rowData[\'online_color\']) ? \'\' : sprintf(\' style="color: %1$s;"\', $rowData[\'online_color\']);
$group_name = sprintf(\'<a href="%1$s?action=admin;area=membergroups;sa=members;group=%2$d"%3$s>%4$s</a>\', $scripturl, $rowData[\'id_group\'], $color_style, $rowData[\'group_name\']);
}



Replace it with:
// Since the moderator group has no explicit members, no link is needed.
if ($rowData[\'id_group\'] == 3)
$group_name = $rowData[\'group_name\'] . \' (\' . $rowData[\'id_group\'] . \')\';
else
{
$color_style = empty($rowData[\'online_color\']) ? \'\' : sprintf(\' style="color: %1$s;"\', $rowData[\'online_color\']);
$group_name = sprintf(\'<a href="%1$s?action=admin;area=membergroups;sa=members;group=%2$d"%3$s>%4$s</a>\', $scripturl, $rowData[\'id_group\'], $color_style, $rowData[\'group_name\']) .  \' (\' . $rowData[\'id_group\'] . \')\';
}



Find:
$colorStyle = empty($rowData[\'online_color\']) ? \'\' : sprintf(\' style="color: %1$s;"\', $rowData[\'online_color\']);
return sprintf(\'<a href="%1$s?action=moderate;area=viewgroups;sa=members;group=%2$d"%3$s>%4$s</a>\', $scripturl, $rowData[\'id_group\'], $colorStyle, $rowData[\'group_name\']);



Replace it with:
$colorStyle = empty($rowData[\'online_color\']) ? \'\' : sprintf(\' style="color: %1$s;"\', $rowData[\'online_color\']);
return sprintf(\'<a href="%1$s?action=moderate;area=viewgroups;sa=members;group=%2$d"%3$s>%4$s</a>\', $scripturl, $rowData[\'id_group\'], $colorStyle, $rowData[\'group_name\']) . \' (\' . $rowData[\'id_group\'] . \')\';







This code will give you the effect shown in Screen Shot 2

Open Sources\ManageMembergroups.php (Make backup if file before editing it)

Find:
'get_items' => array(
'file' => $sourcedir . '/Subs-Membergroups.php',
'function' => 'list_getMembergroups',
'params' => array(
'regular',
),
),
'columns' => array(


Add After:
'id' => array(
'header' => array(
'value' => $txt['membergroups_id'],
),
'data' => array(
'function' => create_function('$rowData', '
global $scripturl;
$group_id = \' (\' . $rowData[\'id_group\'] . \')\';
return $group_id;
'),
'style' => 'text-align: center',
),
'sort' => array(
'default' => 'id_group',
'reverse' => 'id_group DESC',
),
),


Find:
'get_items' => array(
'file' => $sourcedir . '/Subs-Membergroups.php',
'function' => 'list_getMembergroups',
'params' => array(
'post_count',
),
),
'columns' => array(


Add After:
'id' => array(
'header' => array(
'value' => $txt['membergroups_id'],
),
'data' => array(
'function' => create_function('$rowData', '
global $scripturl;
$group_id = \' (\' . $rowData[\'id_group\'] . \')\';
return $group_id;
'),
'style' => 'text-align: center',
),
'sort' => array(
'default' => 'id_group',
'reverse' => 'id_group DESC',
),
),


In Themes\Default\Languages\Modifications.english.php
Find:
?>

Add Before:
$txt['membergroups_id'] = 'ID';





Screen Shot 1:



Screen Shot 2:

Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Yigal

Nice feature :)
Has this already been packaged into a modification?
Yigal V.
Contact me by PM


do yourself a favour and not annoy support helpers by spamming or messaging for support
1.x Support | 2.x Support | 5Mods

Matthew K.

What would be cool...is if you made it another column rather than adding it to the name. Then you could also sort it. It would be fairly simple. I'll give you the edits if you'd like?

Joker™

Quote from: Yigal on January 13, 2011, 01:54:04 PM
Nice feature :)
Has this already been packaged into a modification?
I haven't seen such modification yet.


Quote from: Labradoodle-360 on January 13, 2011, 01:58:18 PM
What would be cool...is if you made it another column rather than adding it to the name. Then you could also sort it. It would be fairly simple. I'll give you the edits if you'd like?
I'll give it a shot, if I find some difficulty I'll surely ask you. Thanks for the suggestion.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Matthew K.

As you already have somewhat of an understanding of how information is added/changed for that section, it should be fairly straight forward to figure out, although, feel free to shoot me a PM if you come up with any questions.

Joker™

Quote from: Labradoodle-360 on January 14, 2011, 12:58:52 AM
As you already have somewhat of an understanding of how information is added/changed for that section, it should be fairly straight forward to figure out, although, feel free to shoot me a PM if you come up with any questions.
Done and code added above in 1st post.

P.S - I can't remove or attach any further screen shot in my above post.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Matthew K.


Joker™

Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Acans

"The Book of Arantor, 17:3-5
  And I said unto him, thy database query shalt always be sent by the messenger of $smcFunc
  And $smcFunc shall protect you against injections and evil
  And so it came to pass that mysql_query was declared deprecated and even though he says he is not
  dead yet, the time was soon to come to pass when mysql_query shall be gone and no more

Joker™

I'm thinking of modding this, as people might end up messing there forums while editing files. (Talking of new users). What do you guys say?
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Acans

Quote from: Joker™ on January 16, 2011, 04:41:20 AM
I'm thinking of modding this, as people might end up messing there forums while editing files. (Talking of new users). What do you guys say?

I say go for it. JBlaze recently started helping out with the mod que so hopefully it doesn't take to long.
"The Book of Arantor, 17:3-5
  And I said unto him, thy database query shalt always be sent by the messenger of $smcFunc
  And $smcFunc shall protect you against injections and evil
  And so it came to pass that mysql_query was declared deprecated and even though he says he is not
  dead yet, the time was soon to come to pass when mysql_query shall be gone and no more

Joker™

Quote from: ѕησω on January 16, 2011, 05:21:44 AM
I say go for it. JBlaze recently started helping out with the mod que so hopefully it doesn't take to long.
Yup, saw a lot of mods approved yesterday. Will be submitting this as a mod by today only ;).
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Matthew K.

If you don't submit it, you could at least write up the package and add it to this topic...just make sure you add that it's not an official mod or tested by the Customization Team.

Yigal

This would make a nice modification.  I think it'd be popular... I'd use it xP. 
Yigal V.
Contact me by PM


do yourself a favour and not annoy support helpers by spamming or messaging for support
1.x Support | 2.x Support | 5Mods

Joker™

Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Acans

"The Book of Arantor, 17:3-5
  And I said unto him, thy database query shalt always be sent by the messenger of $smcFunc
  And $smcFunc shall protect you against injections and evil
  And so it came to pass that mysql_query was declared deprecated and even though he says he is not
  dead yet, the time was soon to come to pass when mysql_query shall be gone and no more

Joker™

Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Acans

lazy :P

That's ok, i made a T&T for lazy admins like you :P
"The Book of Arantor, 17:3-5
  And I said unto him, thy database query shalt always be sent by the messenger of $smcFunc
  And $smcFunc shall protect you against injections and evil
  And so it came to pass that mysql_query was declared deprecated and even though he says he is not
  dead yet, the time was soon to come to pass when mysql_query shall be gone and no more

Joker™

Yeah I remember your T&T, and as I said before it made me more lazy ;D.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Acans

There was nothing lazy about making it tho. Switching between admin.php and subs.php got annoying after a while lol.
"The Book of Arantor, 17:3-5
  And I said unto him, thy database query shalt always be sent by the messenger of $smcFunc
  And $smcFunc shall protect you against injections and evil
  And so it came to pass that mysql_query was declared deprecated and even though he says he is not
  dead yet, the time was soon to come to pass when mysql_query shall be gone and no more

Advertisement: