Random banners in a page

Author Message

Alfredo Cruz

Tuesday 11 November 2008 10:10:39 am

How can I make a page show different banners (images or flash) everytime it's requested?

For instance, I have a flash banner, and I want that flash banner to appear 90% of the time the page is loaded. The other 10%, I want another flash banner.

I also have an image, which I want it to appear 30% of the time, another image 30% of the time, and the final image 40%.

How can I accomplish that.

Thanks..!!

André R.

Wednesday 12 November 2008 12:41:39 am

Output all the banners as hidden HTML and show one using javascript, this way you won't have to disable any cache or anything.

If there are a lot of banners then this wouldn't work (to much markup) and something should be done using a count fetch(to get total) and random operator to select banner using the random number as offset for the fetch (with limitation 1). This needs to be done outside any cache though.

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

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

eZ debug

Timing: Jan 18 2025 15:19:20
Script start
Timing: Jan 18 2025 15:19:20
Module start 'layout'
Timing: Jan 18 2025 15:19:20
Module start 'content'
Timing: Jan 18 2025 15:19:21
Module end 'content'
Timing: Jan 18 2025 15:19:21
Script end

Main resources:

Total runtime1.0680 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0066 591.5625152.6250
Module start 'layout' 0.00660.0027 744.187539.4453
Module start 'content' 0.00931.0576 783.6328522.4375
Module end 'content' 1.06690.0010 1,306.07038.1641
Script end 1.0679  1,314.2344 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.2946160.0002
Check MTime0.00130.1241160.0001
Mysql Total
Database connection0.00090.080910.0009
Mysqli_queries1.029896.4253540.0191
Looping result0.00040.0386520.0000
Template Total1.038497.220.5192
Template load0.00200.187920.0010
Template processing1.036497.042620.5182
Template load and register function0.00010.008110.0001
states
state_id_array0.00080.071810.0008
state_identifier_array0.00160.151120.0008
Override
Cache load0.00160.1540120.0001
Sytem overhead
Fetch class attribute can translate value0.00050.046520.0002
Fetch class attribute name0.00090.080030.0003
XML
Image XML parsing0.00050.044720.0002
class_abstraction
Instantiating content class attribute0.00000.000830.0000
General
dbfile0.00060.0599170.0000
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
2content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 7
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs