News:

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

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?

DBan

Quote from: Antechinus on April 14, 2012, 04:03:56 AM
Is this new class getting echoed to the browser?

I'm not sure how ill be able to tell

Antechinus


DBan

Quote from: Antechinus on April 14, 2012, 04:16:03 AM
Right click > View page source

I'm so sorry but what do I look for in the page source? index.css?

Antechinus

Taking this page as an example, a few hundred lines down is this:

<div id="forumposts">
<div class="cat_bar">
<h3 class="catbg">
<img src="http://media.simplemachinesweb.com/smf/default/images/topic/hot_post.gif" align="bottom" alt="" />
<span id="author">Author</span>
Topic: Color staff's post background? &nbsp;(Read 360 times)
</h3>
</div>
<form action="http://www.simplemachines.org/community/index.php?action=quickmod2;topic=473991.20" method="post" accept-charset="UTF-8" name="quickModForm" id="quickModForm" style="margin: 0;" onsubmit="return oQuickModify.bInEditMode ? oQuickModify.modifySave('30caa8efdbf8e5a01988120a9c78334b', 'aa53d92f') : false">
<div class="windowbg">
<span class="topslice"><span></span></span>


The last bit is the important part. First post on this page is <div class="windowbg">. You're looking for something that says <div class="windowbg staff_post">

Easiest way to find the right line would be to use the broswer's find function to search for the word topslice.

DBan

Quote from: Antechinus on April 14, 2012, 04:27:01 AM
Taking this page as an example, a few hundred lines down is this:

<div id="forumposts">
<div class="cat_bar">
<h3 class="catbg">
<img src="http://media.simplemachinesweb.com/smf/default/images/topic/hot_post.gif" align="bottom" alt="" />
<span id="author">Author</span>
Topic: Color staff's post background? &nbsp;(Read 360 times)
</h3>
</div>
<form action="http://www.simplemachines.org/community/index.php?action=quickmod2;topic=473991.20" method="post" accept-charset="UTF-8" name="quickModForm" id="quickModForm" style="margin: 0;" onsubmit="return oQuickModify.bInEditMode ? oQuickModify.modifySave('30caa8efdbf8e5a01988120a9c78334b', 'aa53d92f') : false">
<div class="windowbg">
<span class="topslice"><span></span></span>


The last bit is the important part. First post on this page is <div class="windowbg">. You're looking for something that says <div class="windowbg staff_post">

Easiest way to find the right line would be to use the broswer's find function to search for the word topslice.

Ah, it's not being echoed in. What should I do? I used CTRL+F to search for staff, but nothing came up

Antechinus

That means we bollixed up the conditionals somehow and you need someone smarter. :D

I know what's wrong with it. I just nicked some code for showing a menu button to a membergroup, but that doesn't tell it to associate the class with the group of the actual person who posted it. It needs something like:

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

That still may not be correct syntax though. I'll fire up a test site and see if I can get it to work.

DBan

Quote from: Antechinus on April 14, 2012, 04:35:27 AM
That means we bollixed up the conditionals somehow and you need someone smarter. :D

I know what's wrong with it. I just nicked some code for showing a menu button to a membergroup, but that doesn't tell it to associate the class with the group of the actual person who posted it. It needs something like:

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

That still may not be correct syntax though. I'll fire up a test site and see if I can get it to work.

Ok, thanks! :)

Antechinus

OK, I'm stumped for the moment. It'll be something really simple. The general idea given above will work. It's just a matter of getting the variables right. Someone will know the right syntax.

DBan

Quote from: Antechinus on April 14, 2012, 05:21:30 AM
OK, I'm stumped for the moment. It'll be something really simple. The general idea given above will work. It's just a matter of getting the variables right. Someone will know the right syntax.


Alright, thanks for helping anyways :)

NanoSector

Try this syntax:

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

No idea if that'll work.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

DBan

Quote from: Yoshi2889 on April 14, 2012, 05:41:19 AM
Try this syntax:

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

No idea if that'll work.
Unfortunately it doesn't :(

NanoSector

#31
Are you getting errors in your error log with that piece?

EDIT: Does this topic help you any further?
http://www.simplemachines.org/community/index.php?topic=454651.0
(thanks Illori)
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Colin

Would you mind sharing a link to your site? That way we can take a look.
"If everybody is thinking alike, then somebody is not thinking." - Gen. George S. Patton Jr.

Colin

NanoSector

My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Colin

No the users who is trying to make the change to the staff post background color.
"If everybody is thinking alike, then somebody is not thinking." - Gen. George S. Patton Jr.

Colin

DBan

Quote from: Yoshi2889 on April 14, 2012, 06:09:08 AM
Are you getting errors in your error log with that piece?

EDIT: Does this topic help you any further?
http://www.simplemachines.org/community/index.php?topic=454651.0
(thanks Illori)
I have done that, it does have an effect, but that effect adds a big space before the post, but within the same block.
Quote from: Colin on April 14, 2012, 10:29:09 AM
Would you mind sharing a link to your site? That way we can take a look.
Sure, here you go: http://nvcnr.info [nofollow]

NIAB

I know this is a little old, but here's the script I am using for backgrounds. Im using an image rather than colors, but its all set up in the divs.
Find: (I think)
echo ' echo'<div class="poster">
Replace with:
echo'<div class=" '  , $message['member']['group_id'] == 1 ? 'admin_poster' : 'poster' , '"> ';

echo '


Make sure you have a div set up for it, Im using admin_poster as an example.
Its pretty neat, I also have one in place for avatar glow :) Hope it helps future SMFers

Advertisement: