MyBB Community Forums

Full Version: Change the theme for night and day? *Code here*
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I am building a site that will have 2 themes, 'Night' and 'Day', this will be on on php script that will hopefully change the themes round at 6am and 6pm. I was wondering if there was anyway to do this with the forums?

I currently working on my day theme LINK

I have found a php script (link) that changes the CSS, so i was wondering if i remove the CSS and put in the bit were is selects the theme to use it would work? Only problem is i don't no were this is.

1 more problem is i don't want it to change the theme in my 'Gaming' section. That has its own theme and doesn't want to change with the 'night' and 'day' theme on the rest of the forums.

Thanks
Interesting idea and shouldn't be too hard to accomplish actually.

Can I ask if your host allows cron jobs? This might be best suited as a cron php where it simply rewrites default theme and rebuilds setting twice a day. Otherwise a script could do a check constantly but then that's a waste imho of resources. The next version of mybb will have a TASKS system which will simplify making things with time based sensativity.
Would it choose the theme based off server time or visitor time?
I would say server time, if easyer.

I am currently running on free hosting, but i am about to buy hosting this week. So i will be able to tell you then.

Thanks for feedback

EDIT: Yep the free hosting will allow the 'cron.php' file you asked about, i hope its 'cron.php'. I have never heard of it before so... I tested it by uploading a file called 'test.cron.php' and it uploaded fine. Is there any other way i can check if it will work?

Thanks

EDIT 2: Ok noob has done is homework and found that cron is run on CMD and is not a file lang. O dear... I am a big noob, lol. So no i can't run anything like that. I dont even think so with buying the hosting. So is there any over way?
Here's a file edit version:
Open global.php

Find:
// This user has a custom theme set in their profile
if(isset($mybb->user['style']) && intval($mybb->user['style']) != 0)
{
	$loadstyle = "tid='".$mybb->user['style']."'";
}
Below Add
$time = date("H");
if ($time >= 6 && $time < 18 ) {
	$loadstyle="tid='".intval(DAY THEME TID)."'";
 } else
 {
 	$loadstyle="tid='".intval(NIGHT THEME TID)."'";
 }
To set your gaming forum theme, set it to override in the ACP.

PLEASE NOTE: THIS WILL OVERRIDE ANY THEME A USER HAS SET
I wuv U!

Thats great, easy as pie. Well i will have to make the night theme now i suppose... Lol

Thats a lot, the gameing theme is already set to override so thats fine. Thanks a lot

EDIT:

O ummm is this the bit i change depending on the name of the theme:
'DAY THEME TID'
EG: $loadstyle="tid='".intval(DAY THEME TID)."'";
It would be the tid. You can find it by looking at the links to edit that theme, or by checking in phpMyAdmin

Just remove the the DAY THEME TID and replace it...
Thanks, just did it at 5.52, lol good timeing. Lets how its work!

LINK!

Thanks a lot!

EDIT! Woot! It worked, i though the server might not be on GMT, but there are, thanks a lot, that rules!
I'm a bid confused with the 'tid' do I take all that out and replace with my forum theme name ei 'dark' ?
No, you need the theme id. Not the theme name.
Pages: 1 2