Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Aiheen aloitti: mack420 - tammikuu 31, 2020, 05:34:25 IP

Otsikko: table background?
Kirjoitti: mack420 - tammikuu 31, 2020, 05:34:25 IP
ok, so i am wondering how to change the default background for tables you create in posts and let me further explain what I mean

I know you can't do when making a new post

I was wondering if there is a edit in the code for the forum template to change the default background for creating new tables as I currently see a white background in tables I create in posts

I just want to be able to match the background color of my forum which is black

is that possible or not?

I hope someone can understand what I mean
Otsikko: Re: table background?
Kirjoitti: drewactual - tammikuu 31, 2020, 05:49:44 IP
add to the bottom of your theme's CSS file:


table.post, th.post, tr.post, td.post {background:#000;}


^as a starting point.
Otsikko: Re: table background?
Kirjoitti: mack420 - tammikuu 31, 2020, 05:56:05 IP
ok, i added it to the bottom of my theme's css file. that would be index.css, right?
Otsikko: Re: table background?
Kirjoitti: mack420 - tammikuu 31, 2020, 06:08:38 IP
is there more to do? the background color is still white
Otsikko: Re: table background?
Kirjoitti: drewactual - tammikuu 31, 2020, 06:31:42 IP
hold shift hit refresh... you may have cached css playing a role.
Otsikko: Re: table background?
Kirjoitti: drewactual - tammikuu 31, 2020, 06:45:31 IP
actually, just use:

td.post{background:#000}

td being 'cell'... tr being 'row'... table, obviously, being the whole table... th being 'table header' which i don't think SMF uses in its default form though some themes may use it?

just 'td' ought to do the trick...

the #000 is short hex for black...
Otsikko: Re: table background?
Kirjoitti: mack420 - tammikuu 31, 2020, 07:14:59 IP
not working
Otsikko: Re: table background?
Kirjoitti: mack420 - tammikuu 31, 2020, 07:20:20 IP
when you said add it as a starting point, what did you mean?
Otsikko: Re: table background?
Kirjoitti: drewactual - tammikuu 31, 2020, 07:34:19 IP
once you get control of it, you can adjust the css...

post a link to a thread with a table, i'll take a look.
Otsikko: Re: table background?
Kirjoitti: mack420 - tammikuu 31, 2020, 07:37:57 IP
get control of it?

I added the line you gave me and saved it and it didn't work

here is a link to a thread with a table in it

http://sefwun.com/forum/index.php?topic=4374.msg6072#msg6072
Otsikko: Re: table background?
Kirjoitti: drewactual - tammikuu 31, 2020, 07:47:15 IP
open up a incognito tab in your browser and look... it has a black background.  however, your font is also black which hides it. 

change the line i offered to this:

td.post{background:#000;color:#fff;}

your cache is holding on to your OLD css... get a fresh copy of your css, if using chrome, firefox, or edge, by holding teh shift key and hitting refresh.
Otsikko: Re: table background?
Kirjoitti: mack420 - tammikuu 31, 2020, 07:54:43 IP
i've tried holding the shift key and hitting refresh, both ways by using the F5 buttton and clicking the refresh symbol in the browser.

I am using Torch browser and have tried pale moon and comodo dragon browsers with the same result, the background is white

i tried clearing the cache in my browser and shutting it down and opening it back up, still white
Otsikko: Re: table background?
Kirjoitti: drewactual - tammikuu 31, 2020, 07:59:49 IP
black on chrome and firefox.  see attached.

Otsikko: Re: table background?
Kirjoitti: drewactual - tammikuu 31, 2020, 08:04:44 IP
now listen to me....

look at the attached... look at the last thing on the bottom... it is:

td.post{background:#000;color:#fff;}

your font is black and so is the background color so you can't see it, which is why 'color:#fff (or white)" was added... now that you'e 'got a hold of it' using td.table div class command, and changed the colors- now, play with it until you like it. 
Otsikko: Re: table background?
Kirjoitti: mack420 - tammikuu 31, 2020, 08:16:55 IP
not worried about the font color being black, i made it black because of white background

i cleared my cache, cookies, browsing history, and i got signed out, saw a black background, signed in and it was white again. i tried clearing just my cach and stayed signed in, still white?????
Otsikko: Re: table background?
Kirjoitti: drewactual - tammikuu 31, 2020, 08:19:49 IP
yeah, you've got a cache issue somewhere.. it may be on your end, or it could be somewhere you have no hope to change such as an ISP's... they seem to cache to make things look faster and to reduce bandwidth... it's super frustrating...

give it an hour or so... maybe a couple hours... it'll be picked up soon.
Otsikko: Re: table background?
Kirjoitti: mack420 - tammikuu 31, 2020, 08:22:47 IP
should i try disconnecting my pc from the internet or restarting my pc?

i think i had to restart my pc once before over a cache issue, maybe i'll just try it?
Otsikko: Re: table background?
Kirjoitti: drewactual - tammikuu 31, 2020, 08:29:58 IP
probably a good idea to remove something on your end from the equation...
Otsikko: Re: table background?
Kirjoitti: mack420 - tammikuu 31, 2020, 08:50:06 IP
i restarted my pc, no help

any ideas???
Otsikko: Re: table background?
Kirjoitti: mack420 - tammikuu 31, 2020, 08:50:34 IP
or rather than ideas, solutions???
Otsikko: Re: table background?
Kirjoitti: mack420 - tammikuu 31, 2020, 10:21:43 IP
ok, so it seems that only members of the site can't see the change made to the background

another member of my site has same problem and it would seem drew who responded to me could see the change and i am assuming he was not signed into an account, so any help with would be greatly appreciated

it doesn't seem to be a cache issue
Otsikko: Re: table background?
Kirjoitti: drewactual - tammikuu 31, 2020, 11:15:08 IP
it is a cache issue. 

you may have an expires header in your htaccess or your host may have one in their httpd that sets an extraordinary amount of time on your css file, or, you're using a chopped theme that eliminated the time stamp on css's as SMF does 'out of the box'.  there are several different kinds of cache's and there are several different ways to leverage them, which makes it difficult to accomplish and makes 'cache busting' a big business. 

so you ask me what can be done, and i'll tell you... but... it is a HACK... i can hack like nobody's business but i DON'T LIKE IT. 

1- open your index.template.php for the theme you're using... find the call to css... it'll look something like:
<link rel="stylesheet" type="text/css" href="yourwebsite.com/css/index.css?fnl" />

you see those letters after the '?' ? well, they tell the server to check the time stamp for all practical purposes.... make sure yours has one...

if it doesn't, add it... and save and see what happens...

if it doesn't work, here comes the hack:

2- RIGHT BEFORE THE </head> tag, add another line something like:
<link rel="stylesheet" type="text/css" href="yourwebsite/css/index.css?fnl" />


EXCEPT instead of index.css, name it "booster-custom.css"...

save, close. 

2B:  make a new file on your server that is in the same directory as your themes's css... name that file "booster-custom.css"... INSIDE booster-custom,css add the css code from earlier :
td.post{background-color:#000;color:#fff;}

what we've done is add another call in your header, which makes the server make an additional trip to apply that css... you 'could' hard code the css into the header, BUT- it may or may not 'take' depending on which happens first, as the css applied will be the last one called... calling it in it's own sheet and at the very last moment DOES slow things down a touch, but... it WILL force this new change...

DON'T remove the code from the index.css- leave it there... sooner or later that css will be applied.  it may be sooner... it may be later... every once in a while see if it does- and when it does? remove the booster-custom.css call in the index.template. 

here is the punch line:  if your server is caching or some switch/hub along the way is caching, IT WILL PICK THIS CHANGE UP and cache it too...... which means that will stick just as the problem you have now does.   do you see how this kind of 'hack' can get out of hand?

caches rock... and caches suck. 

good luck, brother.


Otsikko: Re: table background?
Kirjoitti: drewactual - tammikuu 31, 2020, 11:25:47 IP
actually, i just looked at your code...

man, no offense- but that is a mess... how many calls is there in that page?  at any rate......

your change needs to happen in a file called ..../Themes/default/css/breeze.min.css.... that is a minimized css without a time stamp check...

add the css snippet to the bottom of that file, and you may as well minimalize it:
td.post{background-color:#000;color:#fff} then save it...

then go to your index.template.php and find the call:
<link href="http://sef4life.com/forum/Themes/default/css/breeze.min.css" rel="stylesheet" type="text/css" />

and make it:
<link href="http://sef4life.com/forum/Themes/default/css/breeze.min.css?fin20" rel="stylesheet" type="text/css" />


in short, the maker of this theme already did what i proposed- they hacked it... in the precise way i said to.... and.... this is why you don't hack- you do it right the first and only time....
Otsikko: Re: table background?
Kirjoitti: mack420 - tammikuu 31, 2020, 11:50:17 IP
how do i open /Themes/default/css/breeze.min.css
Otsikko: Re: table background?
Kirjoitti: drewactual - tammikuu 31, 2020, 11:53:38 IP
are you accessing through cpanel or ftp?  it should be just a matter of locating and opening it?
Otsikko: Re: table background?
Kirjoitti: mack420 - tammikuu 31, 2020, 11:56:41 IP
i am in my site administration

that is where i edit my theme

i can't find the file you are referring to though
Otsikko: Re: table background?
Kirjoitti: drewactual - helmikuu 01, 2020, 12:02:36 AP
ahh.... can you access it through cpanel or ftp?

if not, add this to your index.template.php just before /head... :


<style="text/css">
td.post{background-color:#000!important;color:#fff!important;}
</style>


this is just adding hack to hack... i don't like it... the proper way is to access that min.css file and make the change there... but... this should, uh... 'work'....
Otsikko: Re: table background?
Kirjoitti: mack420 - helmikuu 01, 2020, 12:08:31 AP
i was able to edit the file through cpanel and added

td.post{background-color:#000;color:#fff}

i can't find the line of code in the index.template.php to replace with the line you gave me

I did find this one though

<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?fin20" />';
Otsikko: Re: table background?
Kirjoitti: drewactual - helmikuu 01, 2020, 12:11:44 AP
that's the php line and yes- the one you modify.. i was posting the 'output' of that code...

it looks like it adds the time stamp- which isn't really- it just tells the server when there is a newer version available.

are you set with the addition of that code?
Otsikko: Re: table background?
Kirjoitti: mack420 - helmikuu 01, 2020, 12:14:18 AP
what do i add in? the line you gave me previously?
Otsikko: Re: table background?
Kirjoitti: drewactual - helmikuu 01, 2020, 12:22:58 AP
the easiest way out of this is to add this line to your index.template.php just before the "</head>" tag. 


<style="text/css">
td.post{background-color:#000!important;color:#fff!important;}
</style>


you should be able to refresh your page and see the changes... unless you have OPCache set up, and if you do you'll have to reset that... lets hope you don't.
Otsikko: Re: table background?
Kirjoitti: mack420 - helmikuu 01, 2020, 12:35:36 AP
still not working

am i supposed to modify this line

<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?fin20" />

if so, with what?
Otsikko: Re: table background?
Kirjoitti: drewactual - helmikuu 01, 2020, 12:48:29 AP
that line is right. 

it's the call to that minimized css that needs to be updated... add ?fin20 after .css on that line... it appears just before the head closing tag... but, you still gotta get that css change in it however you can.
Otsikko: Re: table background?
Kirjoitti: mack420 - helmikuu 01, 2020, 12:54:00 AP
that line already has ?fin20 after the .css and the line appears just after the head opening tag, at least that is what I am seeing

is it supposed to be before the head closing tag?
Otsikko: Re: table background?
Kirjoitti: drewactual - helmikuu 01, 2020, 01:04:23 AP
it's fine there.  put:

<style="text/css">
td.post{background-color:#000!important;color:#fff!important;}
</style>
AFTER it but before "</head>".   and that should take care of your issue...
Otsikko: Re: table background?
Kirjoitti: mack420 - helmikuu 01, 2020, 01:06:56 AP
i already have that line

<style="text/css">
td.post{background-color:#000!important;color:#fff!important;}
</style>


just before the closing header tag

should i move up to just after the other line?
Otsikko: Re: table background?
Kirjoitti: mack420 - helmikuu 01, 2020, 01:15:03 AP
ok, new problem

so i went ahead and moved this line up just after the line that is already there

<style="text/css">
td.post{background-color:#000!important;color:#fff!important;}
</style>


and i saved it and i get a white screen with this message in the left corner

Unable to load the 'main_above' template.

*groans*

i'm ready for bed
Otsikko: Re: table background?
Kirjoitti: mack420 - helmikuu 01, 2020, 01:36:18 AP
i went to my cpanel to edit my index.template.php file and removed the code i put after the line that was there, so my site loads up again, but i am back at square one with the background color in the table
Otsikko: Re: table background?
Kirjoitti: m4z - helmikuu 01, 2020, 03:27:25 AP
Is the theme you're editing the same theme your account is using? ;)
Otsikko: Re: table background?
Kirjoitti: mack420 - helmikuu 01, 2020, 11:50:56 AP
yes
Otsikko: Re: table background?
Kirjoitti: shawnb61 - helmikuu 01, 2020, 11:58:11 AP
It may be helpful to turn off minimization while testing. 

I sometimes find that if .css or .js doesn't kick in, I need to:
- delete any auto-minimized .css & .js on the server side
- do a hard refresh (usually shift-F5 or shift-refresh button) to force your browser to reload the files


Otsikko: Re: table background?
Kirjoitti: mack420 - helmikuu 01, 2020, 12:04:23 IP
by the way, i have removed all lines of code i was told to add and if you still view the post in my site as a non member, it shows black background for the table, but for members of the site it shows white??????

i think there is a problem with the theme i am using and after Drew said my coding looked like a mess, no offense taken by the way, idk what to say from here

I installed the pro red theme for my forum a couple years ago or so and ended up editing the colors to be more red and black theme, so perhaps in my edits I messed something up

I don't claim to be a coding expert which is why I come here when I have a problem and I ask for help of the experts, least compared to be you all are

I have tried applying a different them in my forum and it won't change from my current theme, so yea, that maybe a related issue or something different, idk again

In response to shawn, how do you turn off minimization?

I have already tried the hard refresh after adding the lines of code, but as stated above, even without the lines of code added in, the background shows up black for guests, but white for members, so again, I think its a error in the theme itself that I probably caused by being a novice at editing code, idk, maybe the theme is not compatible with my version of smf anymore

again, i am not a expert at this which is why I am here on the support board