News:

Join the Facebook Fan Page.

Main Menu

table background?

Started by mack420, January 31, 2020, 05:34:25 PM

Previous topic - Next topic

mack420

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

drewactual

add to the bottom of your theme's CSS file:


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


^as a starting point.

mack420

ok, i added it to the bottom of my theme's css file. that would be index.css, right?

mack420

is there more to do? the background color is still white

drewactual

hold shift hit refresh... you may have cached css playing a role.

drewactual

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...

mack420


mack420

when you said add it as a starting point, what did you mean?

drewactual

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.

mack420

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

drewactual

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.

mack420

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

drewactual

black on chrome and firefox.  see attached.


drewactual

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. 

mack420

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?????

drewactual

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.

mack420

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?

drewactual

probably a good idea to remove something on your end from the equation...

mack420

i restarted my pc, no help

any ideas???

mack420

or rather than ideas, solutions???

mack420

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

drewactual

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.



drewactual

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....

mack420

how do i open /Themes/default/css/breeze.min.css

drewactual

are you accessing through cpanel or ftp?  it should be just a matter of locating and opening it?

mack420

i am in my site administration

that is where i edit my theme

i can't find the file you are referring to though

drewactual

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'....

mack420

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" />';

drewactual

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?

mack420

what do i add in? the line you gave me previously?

drewactual

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.

mack420

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?

drewactual

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.

mack420

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?

drewactual

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...

mack420

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?

mack420

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

mack420

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

m4z

Is the theme you're editing the same theme your account is using? ;)
"Faith is what you have in things that don't exist."
--Homer Simpson

Es gibt hier im Forum ein deutsches Support-Board!

mack420


shawnb61

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


Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

mack420

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

Advertisement: