News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Color staff's post background?

Started by DBan, April 14, 2012, 02:34:47 AM

Previous topic - Next topic

DBan

Is there any way to put an image behind a staff member's post background? Something like this:


Just something to make staff member's posts more noticeable when scrolling through.

Thanks for your help :)

Robert.

Please attach Display.template.php and I will make the edit for you :)

DBan


Robert.

Find
while ($message = $context['get_message']())

{

Add after
// A list of staff members
$staff = array(
1
);

// Is it staff?
if(in_array($message['member']['id'], $staff))
$background = '{put_class_here}';

Find
<div class="', $message['approved'] ? ($message['alternate'] == 0 ? 'windowbg' : 'windowbg2') : 'approvebg', ''">
Replace with
<div class="', $message['approved'] ? ($message['alternate'] == 0 ? 'windowbg' : 'windowbg2') : 'approvebg', ' ' . $background . '">
I am sure there is a better way, but this is one of the most easiest ways to have what you want. It falls back to the regular background when the specified class doesn't exist.

DBan

Quote from: 医生唱片骑师 on April 14, 2012, 03:00:31 AM
Find
while ($message = $context['get_message']())

{

Add after
// A list of staff members
$staff = array(
1
);

// Is it staff?
if(in_array($message['member']['id'], $staff))
$background = '{put_class_here}';

Find
<div class="', $message['approved'] ? ($message['alternate'] == 0 ? 'windowbg' : 'windowbg2') : 'approvebg', ''">
Replace with
<div class="', $message['approved'] ? ($message['alternate'] == 0 ? 'windowbg' : 'windowbg2') : 'approvebg', ' ' . $background . '">
I am sure there is a better way, but this is one of the most easiest ways to have what you want. It falls back to the regular background when the specified class doesn't exist.

Thanks so much :)

But, I am very new to php and I do not know what you mean by class in {put_class_here}? Could you possibly give me an example of a class?

Thanks for you help.

Best regards,
DBan

Robert.

Well, just add something like this to your css (index.css):

.staff_post {
    background: grey;
}

Then replace {put_class_here} with "staff_post". :)

DBan

Quote from: 医生唱片骑师 on April 14, 2012, 03:12:38 AM
Well, just add something like this to your css (index.css):

.staff_post {
    background: grey;
}

Then replace {put_class_here} with "staff_post". :)

Ah lol thanks so much for your help :)

Robert.


Antechinus

I'd do it by using staff groups for the array, to save you having to list every staff member by their individual id. :)

DBan

Been trying to get it working thinking i'm doing something wrong. I figured out the problem, how do I list the members in the below code? (where the '1' is)

// A list of staff members
$staff = array(
1
);

// Is it staff?
if(in_array($message['member']['id'], $staff))
$background = '{put_class_here}';


Sorry if its just something that can be simply done :/

Robert.

The '1' is a member id (I guess it's your account id so that's why), you can add more by doing something like this:
$staff = array(
    1, 2, 3, 4
);


I'd do it by using staff groups for the array, to save you having to list every staff member by their individual id. :)
True, but didn't know how to get the membergroup id so that's why I did it by adding a member id array :P

DBan

Hmm I have done all this (listed the staff's member ids and such) but the posts are still not being affected :/ Any idea why?

Robert.

What css are you using for the post background?

DBan

/public_html/Themes/default/css/index.css

I've put it in the top of the script:

/* Styles for the general looks for the Curve theme.
------------------------------------------------------- */

/* Staff post */
.staff_post {
    background: #85CCFF;
}



And I am also using the curve theme

Is the right?

Thanks

Antechinus

<div class="', $message['approved'] ? ($message['alternate'] == 0 ? 'windowbg' : 'windowbg2') : 'approvebg', ' ',  (in_array(1,2, $GLOBALS['user_info']['groups'])) ? 'staff_post' : '', '">

That should do it. Well it should if you just have the standard groups 1 and 2 for admins and global mods.

DBan

Quote from: Antechinus on April 14, 2012, 03:42:27 AM
<div class="', $message['approved'] ? ($message['alternate'] == 0 ? 'windowbg' : 'windowbg2') : 'approvebg', ' ',  (in_array(1,2, $GLOBALS['user_info']['groups'])) ? 'staff_post' : '', '">

That should do it. Well it should if you just have the standard groups 1 and 2 for admins and global mods.

It unfortunately still doesn't affect the posts :(

Robert.

Try to move the css code to the bottom of index.css and add a "!important" before the ";" :)

Antechinus

Do a hard refresh. CSS files are cached by your browser, so often you wont see css changes without a forced reload (Ctrl+F5 on Windows).

DBan

Quote from: Antechinus on April 14, 2012, 03:54:50 AM
Do a hard refresh. CSS files are cached by your browser, so often you wont see css changes without a forced reload (Ctrl+F5 on Windows).
Quote from: 医生唱片骑师 on April 14, 2012, 03:54:07 AM
Try to move the css code to the bottom of index.css and add a "!important" before the ";" :)

Unfortunately those still haven't solved my problem :(

Antechinus

Is this new class getting echoed to the browser?

Advertisement: