News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

[Implemented] Membergroup colours in posts

Started by dracomiconia, May 17, 2004, 05:38:38 AM

Previous topic - Next topic

dracomiconia

I have seen this before, but I think it wasn't in feature forums...

Tomer

This is an easy mod to change. If you want help changing this, post here and I will guide you through it.

dracomiconia

Tell me how.... I'll be proud of making it myself with a little help.... :P

Yonkey

In \Themes\<your current theme>\Display.template.php:

change:

// Show the member's primary group (like 'Administrator') if they have one.
if (isset($message['member']['group']) && $message['member']['group'] != '')
echo '
', $message['member']['group'], '<br />';

// Don't show these things for guests.
if (!$message['member']['is_guest'])
{
if ($message['member']['post_group'] != '')
echo '
', $message['member']['post_group'], '<br />';


to:

// Show the member's primary group (like 'Administrator') if they have one.
if (isset($message['member']['group']) && $message['member']['group'] != '') {
if (isset($message['member']['group_color']))
echo '
', '<span style="color : ', $message['member']['group_color'],';"><b>', $message['member']['group'], '</b></span><br />';
else
echo '
', $message['member']['group'], '<br />';
}

// Don't show these things for guests.
if (!$message['member']['is_guest'])
{
if ($message['member']['post_group'] != '') {
if (isset($message['member']['post_group_color']))
echo '
', '<span style="color : ', $message['member']['post_group_color'],';">', $message['member']['post_group'], '</span><br />';
else
echo '
', $message['member']['post_group'], '<br />';
}


Enjoy!  :D

dracomiconia

Thank u...

I can see color in membergroup, but not in the name of the poster, but it is almost the thing I was looking for...

Thank u very much.

Oldiesmann

So you want the color to apply to the poster as well? That's easy enough to do...

Open up display.template.php:

find
echo '
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
<tr>
<td valign="top" width="16%" rowspan="2" style="overflow: hidden;">
<b>', $message['member']['link'], '</b><br />
<span class="smalltext">';


replace
echo '
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
<tr>
<td valign="top" width="16%" rowspan="2" style="overflow: hidden;">';

if(isset($message['member']['group']) && $message['member']['group'] != '' && isset($message['member']['group_color']))
{
echo '
<span style="color : ', $message['member']['group_color'] ,';"><b>', $message['member']['link'], '</b></span><br />';
}
else (if(isset($message['member']['post_group_color'] && $message['member']['post_group'] != '' && !$message['member']['is_guest'])
{
echo '
<span style="color : ', $message['member']['post_group_color'] ,';"><b>', $message['member']['link'], '</b></span><br />';
}
else
{
echo '
<b>', $message['member']['link'], '</b><br />';
}
echo '
<span class="smalltext">';

Elijah Bliss

I get this error:
parse error, unexpected T_IF in /xxx/Display.template.php on line 226

using Oldiesman code.

also, where in the Display.template would I be able to show the colors of members in the thread view?

Oldiesmann

Whoops!

Find:
else (if(isset($message['member']['post_group_color'] && $message['member']['post_group'] != '' && !$message['member']['is_guest'])

Replace:
else (if(isset($message['member']['post_group_color']) && $message['member']['post_group'] != '' && !$message['member']['is_guest']))

Elijah Bliss

Quote from: Oldiesmann on May 19, 2004, 10:14:11 PM
Whoops!

Find:
else (if(isset($message['member']['post_group_color'] && $message['member']['post_group'] != '' && !$message['member']['is_guest'])

Replace:
else (if(isset($message['member']['post_group_color']) && $message['member']['post_group'] != '' && !$message['member']['is_guest']))

hmmm. I don't get it. I can't get yours or Yonkey's code to work. With his I get:
Parse error: parse error, unexpected $ in /xxx/Display.template.php on line 693

and I still get the same error code with yours with the corrections. I also tried it on the SMF default template and I still get the same errors. Is this mod for Beta 5 public?

Yonkey

What's on line 693? 

And yes, I'm using 1.0 beta 5  8)

Elijah Bliss

Quote from: Yonkey on May 20, 2004, 12:11:55 AM
What's on line 693? 

And yes, I'm using 1.0 beta 5  8)

The 693 was from my modified template.
The 634, which doesn't matter because both lines lead to the end of the document.

Elijah Bliss

#11
If you like here are my display.templates with the mods:


Yonkey

Can you rename them to .txt, I can't download the file as a .php because your server only shows the compiled versions:

<b>Parse error</b>:  parse error, unexpected $ in <b>Display.template.php</b> on line <b>634</b><br />

Elijah Bliss

Quote from: Yonkey on May 20, 2004, 01:26:35 AM
Can you rename them to .txt, I can't download the file as a .php because your server only shows the compiled versions:

<b>Parse error</b>:  parse error, unexpected $ in <b>Display.template.php</b> on line <b>634</b><br />

I attached the files and labeled the accordingly.

Oldiesmann


Elijah Bliss

Quote from: Oldiesmann on May 20, 2004, 10:23:38 AM
Ok... Try this one.

still no go. Now I get:
Parse error: parse error, unexpected T_IF in /xxx/Display.template.php on line 226

Oldiesmann

Find
else (if(isset($message['member']['post_group_color']) && $message['member']['post_group'] != '' && !$message['member']['is_guest']))

Replace with
elseif(isset($message['member']['post_group_color']) && $message['member']['post_group'] != '' && !$message['member']['is_guest'])

Elijah Bliss

#17
Quote from: Oldiesmann on May 20, 2004, 11:12:33 AM
Find
else (if(isset($message['member']['post_group_color']) && $message['member']['post_group'] != '' && !$message['member']['is_guest']))

Replace with
elseif(isset($message['member']['post_group_color']) && $message['member']['post_group'] != '' && !$message['member']['is_guest'])

Thanks!

The code worked, and I'm no longer getting error messages, but I can't see the colors in their names. The member group colors for admin and moderator are red and blue, where exactly should I look to see the modification?

dschwab9

I thought it was supposed to be safe to attach PHP files in SMF?  Did something change?  It seems to actually execute them now instead of forcing download.

Oldiesmann

Quote from: Elijah Bliss on May 20, 2004, 11:32:09 AM
Quote from: Oldiesmann on May 20, 2004, 11:12:33 AM
Find
else (if(isset($message['member']['post_group_color']) && $message['member']['post_group'] != '' && !$message['member']['is_guest']))

Replace with
elseif(isset($message['member']['post_group_color']) && $message['member']['post_group'] != '' && !$message['member']['is_guest'])

Thanks!

The code worked, and I'm no longer getting error messages, but I can't see the colors in their names. The member group colors for admin and moderator are red and blue, where exactly should I look to see the modification?

You have to define a specific color for each post group.
Admin -> Edit Membergroups
Click on "Modify" next to a membergroup, and put something in the "color in online list" box.

Advertisement: