Random CSS background Images

Author Message

Martin Sanders

Friday 07 April 2006 2:25:02 pm

Hi I've been working on placing a random image in the background of a div, but have found that for some reason the permissions of our eZ publish website server account will not allow our PHP script to select random images. I've found that this issue is related to ez, does anyone know how we can implement such an effect within our ez website.

http://www.alistapart.com/articles/randomizer

Kind regards,

Gabriel Ambuehl

Saturday 08 April 2006 6:29:17 am

You will likely have to put the php script that sends the images to the browser in a directory that is not being covered by mod_rewrite I guess. The specific location depends a lot on your actual mod_rewrite config.

Or write an extension to send out the images...

Visit http://triligon.org

André R.

Saturday 08 April 2006 6:30:03 am

I think they have added a randomizer function in v3.8.
With that you could set different css classes on the body tag, and use css to have different styles / backgrounds based on that class.

body.style1 div#mydiv {bacground: #fff url(my_img.gif) left top no-repeat scroll;}
body.style2 div#mydiv {bacground: #fff url(not_my_img.gif) left top no-repeat scroll;}

In earlier versions you could use time stamps as the randomizer, for instance seconds. You could have 60 different styles That would seem quite random to the surfer as well..

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Mark Marsiglio

Saturday 08 April 2006 8:28:00 am

We did this by using the shuffle contribution and calling images from a special folder in the Media Section.

We set the shuffle operator on a fetch that called images from that folder (by parent node) using a limit of 1. Then the fetch is embedded in an inline style - background-image for that div.

I don't have the code handy, but can post it if you need it.

http://www.thinkcreative.com
Turning Ideas Into Strategic Solutions

Betsy Gamrat

Saturday 08 April 2006 10:32:07 am

Thanks!

I didn't know about <b>shuffle</b> and I need it for the project I'm working on. You just saved me alot of time.

:)

David Jones

Thursday 31 August 2006 9:34:32 am

Mark,

I realize that this was posted some time ago but do you still have that code floating around?

I need to do something similar

Thanks

Claudia Kosny

Thursday 31 August 2006 10:55:23 am

Hello David

The post by Marc Boon in this thread
http://ez.no/community/forum/setup_design/how_to_fetch_random_content_3_8/re_how_to_fetch_random_content_3_8__3
gives a nice solution on how to fetch a single random object (and some ideas on how to fetch more than one)
Limit the fetch to your pictures, grab the path to the picture and add it to your style information.

Greetings from Luxembourg

Claudia

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.