News:

Wondering if this will always be free?  See why free is better.

Main Menu

Membergroup Title Color

Started by SychO, November 03, 2015, 11:12:04 AM

Previous topic - Next topic

SychO

Greetings,

in SMF the member groups are not colored with the same color set in the field "Online List Color"

it's always a normal color, that's why i use HTML in membergroups Title ! and i know that it's bad and won't be good once i update from 2.0.10 to 2.0.11

so i need your help adding a code in Display.template.php and Display.php , so that the membergroup title would be the same as the color set in the Online list color field when managing the membergroups !

I don't have that much knowledge in PHP so anyone's help please ?

regards.


Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

margarett

Even the username shouldn't have a different color in Display.template.php. Are you using a MOD for that?
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

SychO

yes it's a mod <SimpleColorizer> don't worry it's 100% safe
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

margarett

I was asking because it might be possible to just use the information already fetched by the MOD to produce the result you want ;)

The first thing I would advise you to do is to ask the MOD support topic if what you want to do is possible ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

SychO

well i tried actually with the minimum knowledge i have in PHP :3 but didn't go really far

however i don't like asking in mod supports since you don't really get an answer :3

thanks anyways mate !
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

SychO

Well can anyone at least tell me how i can request the poster's group id ?

and then show it as a class and then i'll just add some css settings

thank you
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

Deprecated

Quote from: SychO on November 03, 2015, 11:21:29 AM
yes it's a mod <SimpleColorizer> don't worry it's 100% safe

I'm using the Simple Colorizer mod to accomplish what the OP wants (assuming I understand his post) and it works perfectly!

http://custom.simplemachines.org/mods/index.php?mod=3067

Even better, it doesn't even modify SMF's code. It works by 100% integration hooks.

margarett

I don't think you understand it right :P
Simple Colorizer... Colorizes :P the username. The user wants to colorize the membergroup too.
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Deprecated


SychO

Well what i mean is that i want to some how colorize the membergroup title with it's online list color
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

All Colours Sam

It is possible to colorize the membergroup using that mod but it requires at least two changes, one is to include the user ID on the <li> tag that displays the membergroup

On the default theme that part looks like this:

<li class="membergroup">', $message['member']['group'], '</li>';

Change it to this:

<li class="membergroup" data-memberID="' . $message['member']['id'] . '">', $message['member']['group'], '</li>';

Then open your Sources/Subs-SimpleColorizer.php file and look for this:

if (($user_colors = sc_loadColors($user_ids)) !== false)
foreach ($user_colors as $user_id => $user_color)
$buffer = preg_replace(str_replace('{$user_id}', $user_id, $regex[1]), '$1 style="color: ' . $user_color . ';"', $buffer);


And change it to this:

if (($user_colors = sc_loadColors($user_ids)) !== false)
foreach ($user_colors as $user_id => $user_color)
{
$buffer = preg_replace(str_replace('{$user_id}', $user_id, $regex[1]), '$1 style="color: ' . $user_color . ';"', $buffer);

// Membergroups too!
$buffer = preg_replace(str_replace('{$user_id}', $user_id, 'data-memberID="{$user_id}"'), '$1 style="color: ' . $user_color . ';"', $buffer);
}



Now this is totally untested so use it on a test site or at least made backups of your files before attempting this.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

SychO

Yea there seems to be a problem with the code you made

the page stays blank !

and thnx for you're help mate ! i really appreciate it
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

SychO

or perhaps if someone could show me how i can make the poster 's group ID show

so i can show it as a class and then set some css

it would be good
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

Gluz

Looking at the code in the file, seems like Suki left out the regex delimiters.

In the file /Sources/Subs-SimpleColorizer.php, search:
foreach ($user_colors as $user_id => $user_color)
$buffer = preg_replace(str_replace('{$user_id}', $user_id, $regex[1]), '$1 style="color: ' . $user_color . ';"', $buffer);

And replace with:
foreach ($user_colors as $user_id => $user_color)
{
$buffer = preg_replace(str_replace('{$user_id}', $user_id, $regex[1]), '$1 style="color: ' . $user_color . ';"', $buffer);

// Membergroups too!
//$buffer = preg_replace(str_replace('{$user_id}', $user_id, '~data-memberID="{$user_id}"~'), '$1 style="color: ' . $user_color . ';"', $buffer);
}



In /Themes/your_theme/Display.template.php, search:
<li class="membergroup">', $message['member']['group'], '</li>';
And replace with:
<li class="membergroup" data-memberID="', $message['member']['id'], '">', $message['member']['group'], '</li>';

SychO

hmm Not working for some reason mate ! :/
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

Gluz

You need to check the PHP error_log file and teh SMF error log to see if it says something, I tested the code in my own forum and that's why I see the delimiters thing.

SychO

Here are the errors SMF Detected :

Invalid argument supplied for foreach()

File: /blabla/blabla/blabla/forum/Sources/Subs-SimpleColorizer.php

Line: 23

------------------------------

Undefined variable: user_colors

File: /blabla/blabla/blabla/forum/Sources/Subs-SimpleColorizer.php

Line: 23
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

SychO

ow sorry i deleted an if line by mistake

now the code is working !

thank you very much for your help

♥♥LOVE♥♥
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

aegersz

i installed the colorizer and it's subtle yet cool.

thanks for the heads up.

sweet little mod that plays nice.
The configuration of my Linux VPS (SMF 2.0 with 160+ mods & some assorted manual tweaks) can be found here and notes on my mods can be found here (warning: those links will take you to a drug related forum). My (House) music DJ dedication page is here

Advertisement: