12 replies [Last post]
Phreestyle
Phreestyle's picture
Offline
Enthusiast
Australia
Last seen: 5 years 12 weeks ago
Australia
Timezone: GMT+8
Joined: 2007-05-12
Posts: 235
Points: 6

Hi there,
I've managed to cobble together a site that changes colours and backgrounds whenever the page loads. I've done this by combining CSS and PHP together.

This was in response to a recent poster who enquired about a means of organising a large website that would require fairly regular changes in colours and styles depending on the seasons/holidays. A few people commented at the time, that this kind of project might prove to be a bit of a nightmare to organise.

Anyway, this is my solution. I've used a random number generator in this prototype, but, I think, a PHP date function would work equally well.

I'd be interested to know what you think of this approach to this kind of task.

http://robster.freehostia.com/codemonkey/

Life's a journey. Enjoy the trip.

thepineapplehead
thepineapplehead's picture
Offline
Guru
Last seen: 3 weeks 2 days ago
Joined: 2004-06-30
Posts: 9674
Points: 810

Other than the fact that

Other than the fact that your green background image doesn't tile properly Tongue a very well-executed page. Very handy and very well written and explained Laughing out loud

Verschwindende wrote:
  • CSS doesn't make pies

Phreestyle
Phreestyle's picture
Offline
Enthusiast
Australia
Last seen: 5 years 12 weeks ago
Australia
Timezone: GMT+8
Joined: 2007-05-12
Posts: 235
Points: 6

Thanks for your feedback,

Thanks for your feedback, Pineapplehead.

I think the green background you mentioned does tile, but is just hideously ugly. It was the last one I made, and i was running out of energy at that stage. A new background is on my list of tasks for this weekend.

Life's a journey. Enjoy the trip.

mihirc
mihirc's picture
Offline
Leader
Pune, Maharashtra, India
Last seen: 6 years 35 weeks ago
Pune, Maharashtra, India
Timezone: GMT+5.5
Joined: 2007-05-09
Posts: 728
Points: 204

Yes that is a really good

Yes that is a really good page you made. simple but effective, though the colours are quite high contrast...

mihir Smile

Proprietor - Thoughtfulviewfinder Services
Web Development | Design | Merchandise | Photography
My personal blog: MihirChhatre.com

Phreestyle
Phreestyle's picture
Offline
Enthusiast
Australia
Last seen: 5 years 12 weeks ago
Australia
Timezone: GMT+8
Joined: 2007-05-12
Posts: 235
Points: 6

Thanks mihir. I built it as

Thanks mihir.

I built it as an experiment, but yeah the colours have turned out to be the aspect that are most problematic. I'm trying to work on an algorhythm that will render readable text, but with less contrast. It's usually at this point my brain feels like it might explode.

If anyone has got any ideas or insight regarding this I would be very grateful.

Life's a journey. Enjoy the trip.

burlster
burlster's picture
Offline
Leader
Bournemouth
Last seen: 16 weeks 5 days ago
Bournemouth
Joined: 2007-05-31
Posts: 693
Points: 45

One thing makes me curious.

One thing makes me curious. PHP can automatically get date and time from the server can it not? So therefore, using your technique, would it not be possible to have, say for example, a day time colour during the day, and a moon-lit effect at night... or perhaps leaves in the background come Autumn but falling snow come winter...

What I like about these ideas is the idea your site would effectively be living, but with 0 input from you outside the initial background designs and various CSS files. Of course the downside would be the updating of all CSS files with the various backdrops each time a minor change was made to one of them.

OOOh, unless they were background specific references only, and all imported a general CSS file.

I'm getting quite excited over this. This would be possible right? (If so, it will be a feature of Burlster.com)

Have YOU said Hello yet?
The CSSCreator Hello Thread

Phreestyle
Phreestyle's picture
Offline
Enthusiast
Australia
Last seen: 5 years 12 weeks ago
Australia
Timezone: GMT+8
Joined: 2007-05-12
Posts: 235
Points: 6

Hi John, Yeah, my first

Hi John,
Yeah, my first version used two stylesheets. The first with all the main attributes and, the second, which shifted colour and layout (switching a sidebar from left to right). Here's a link if you are interested.

http://robster.freehostia.com/switcher/

I liked the idea, but the code bagan to get a bit cumbersome. The site I posted to the forum is version two and the code is much much lighter. I've also built a calendar site, that changes the text and images every day by using PHP.

I'm really digging the interaction between CSS and PHP.

Life's a journey. Enjoy the trip.

burlster
burlster's picture
Offline
Leader
Bournemouth
Last seen: 16 weeks 5 days ago
Bournemouth
Joined: 2007-05-31
Posts: 693
Points: 45

Yeah sure, By reading in

Yeah sure,

By reading in the dates and times and what not, you can then calculate which CSS file should be used do it that way!

I have also enjoyed the interaction between CSS and PHP. I think something I'm working on at the moment does it to a degree. Each page is given a name and a category. Then PHP then says 'if it's such-and-such a category, write this line'. The line it writes is CSS that slots in to the HTML overwriting a 'hidden' sub-menu and highlighting the page your on. With nothing more then a page identifier in CSS, I can create an interactive drop down menu (albeit not the clever sort. If it drops down, it does so taking the rest of the menu with it...)

Fun!

Have YOU said Hello yet?
The CSSCreator Hello Thread

mihirc
mihirc's picture
Offline
Leader
Pune, Maharashtra, India
Last seen: 6 years 35 weeks ago
Pune, Maharashtra, India
Timezone: GMT+5.5
Joined: 2007-05-09
Posts: 728
Points: 204

I agree that it would work

I agree that it would work great if we could do something like that. but if that site is gonna be managed by a client, it would really be a lot of explaining. Phreestyle i am ready to contribute, but after the 20th... am off on a jungle trek now.

mihir Smile

Proprietor - Thoughtfulviewfinder Services
Web Development | Design | Merchandise | Photography
My personal blog: MihirChhatre.com

Phreestyle
Phreestyle's picture
Offline
Enthusiast
Australia
Last seen: 5 years 12 weeks ago
Australia
Timezone: GMT+8
Joined: 2007-05-12
Posts: 235
Points: 6

A jungle trek sounds pretty

A jungle trek sounds pretty cool. Lucky you.

If you have a spare moment maybe you could try to find a way to make 16 million colours conform to a ratio of 5:1 (as set out in the W3C guidelines) when neither the 5 or the 1 are known entities.

Enjoy your trek. Hope you see some cool butterflies.

Life's a journey. Enjoy the trip.

mihirc
mihirc's picture
Offline
Leader
Pune, Maharashtra, India
Last seen: 6 years 35 weeks ago
Pune, Maharashtra, India
Timezone: GMT+5.5
Joined: 2007-05-09
Posts: 728
Points: 204

Hi, i am finally back from

Hi,
i am finally back from the trip, with some good photographs and a lot of travelling. Anyways, taking a hint from your project i have taken it a further and added a colour picker, to it. I have also made it such that it once the form is submitted, the input fields have that colour.
I am making it as a component, but i will put it up on one of the test servers for you to see.
I am working on it currently on my local server and it will be a couple of days to put it up. As i mentioned i have just taken a hint from your idea, what i am working is something different,

i wont disclose it now... but will post the link in a couple of days.

mihir.
Photos: www.flickr.com/photos/thoughtfulviewfinder

Proprietor - Thoughtfulviewfinder Services
Web Development | Design | Merchandise | Photography
My personal blog: MihirChhatre.com

ABCruz
ABCruz's picture
Offline
Enthusiast
Pilipinas
Last seen: 6 years 49 weeks ago
Pilipinas
Timezone: GMT+8
Joined: 2005-06-16
Posts: 279
Points: 0

Good project!!! I'll

Good project!!! Laughing out loud
I'll bookmark the page for later reference.

Cheers!

Arielle

I am a Man of Truth.
I am a Free Human Person.
I am a Peacemaker.

http://www.abcruz.com

Phreestyle
Phreestyle's picture
Offline
Enthusiast
Australia
Last seen: 5 years 12 weeks ago
Australia
Timezone: GMT+8
Joined: 2007-05-12
Posts: 235
Points: 6

mihir, Those are nice

mihir,
Those are nice photographs. i'm glad your trek went well. You could build a cool butterfly related site using your photographs.

I'll be very interested to see your PHP switching ideas in action. They sound very interesting.

AbCruz,
thanks. I hope you can find a use for some of the ideas.

Life's a journey. Enjoy the trip.