Forums / Setup & design / Random CSS background Images

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

eZ debug

Timing: Jan 19 2025 09:38:28
Script start
Timing: Jan 19 2025 09:38:28
Module start 'content'
Timing: Jan 19 2025 09:38:29
Module end 'content'
Timing: Jan 19 2025 09:38:30
Script end

Main resources:

Total runtime1.9637 sec
Peak memory usage4,096.0000 KB
Database Queries216

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0072 590.0859180.8359
Module start 'content' 0.00721.7692 770.9219771.7578
Module end 'content' 1.77640.1871 1,542.6797340.4375
Script end 1.9635  1,883.1172 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00490.2485210.0002
Check MTime0.00180.0925210.0001
Mysql Total
Database connection0.00090.044510.0009
Mysqli_queries1.860494.74022160.0086
Looping result0.00310.15962140.0000
Template Total1.904897.020.9524
Template load0.00310.156220.0015
Template processing1.901796.844820.9509
Template load and register function0.00020.012710.0002
states
state_id_array0.01500.764410.0150
state_identifier_array0.00420.211520.0021
Override
Cache load0.00300.1516380.0001
Sytem overhead
Fetch class attribute can translate value0.00270.135980.0003
Fetch class attribute name0.00140.0702100.0001
XML
Image XML parsing0.00410.207980.0005
class_abstraction
Instantiating content class attribute0.00000.0010100.0000
General
dbfile0.00630.3229390.0002
String conversion0.00000.000530.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 24
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs