I agree that you have to consider the volume of traffic, and single
threading issues.  However, I would be assuming that the banner rotator
would be a javascript function on a page, or a CFM file retrieved via
CFHTTP.  In this case, I'd just use CF to build a javascript array of the
necessary URLs for each page.  Then the array/ordered collection does not
need to be in the application scope, it would be a local variable.

But, I do see ways to shoot that idea out of the water too.  I guess it
comes down to my in-experience with banner rotators, and banner ads in
general.  So, I will follow the list's guidance on this topic.

My $0.25 worth.

Shawn Grover

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 06, 2002 3:10 AM
To: CF-Talk
Subject: RE: Rotating banners


It all depends really on the level of traffic on the site.
The higher the traffic then the larger the sample and the closer the random
selection from the weighted list will get to the desired result.
To use Shawn's ordered collection from a randomly distributed list you'd
need to hold it or at least the latest selection in an application variable
which would move each time it was accessed. This would be problematic for a
high traffic site, since you'd have to single thread access to this part of
the application.cfm.
For a low traffic site this would give a better approximation and the
application variable might access might not be a problem.

-----Original Message-----
From: Shawn Grover [mailto:[EMAIL PROTECTED]]
Sent: 05 March 2002 19:03
To: CF-Talk
Subject: RE: Rotating banners


I don't think this will work well....

Yes, you have listed the banner ID's in the proper percentage, but there is
no guarantee that the random number will
match that weighting.

For instance, a random number generator could (in theory) produce
"1,1,1,1,1,1,4,5,1,1".  Now, if the ID at position 1 was weighted for 10%,
they are really getting more than 10% in this case.  The problem being that
you can't rely on a random number to pick the weighted elements.

A different option would be to maybe do like Ben mentioned below in creating
a list or array of the elements, but randomly distribute the IDs within the
Array (you've already determined how many there should be of each ID based
on the weight).  Then, you just need to loop through the list or array,
showing the next element.  This would result in the proper weighting, I
think.

Then again, I've never had to worry about rotating banners - but I'm
normally good at finding holes in solutions (sorry Ben).

Shawn Grover

-----Original Message-----
From: BEN MORRIS [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 05, 2002 11:35 AM
To: CF-Talk
Subject: Re: Rotating banners


I would think that you would loop through your query, and build a list.
For each query record, loop from 1 to the weight value, and add the
bannerID to the a list called bannerIDList for each nested loop.  This way
if you have one banner with bannerID=301 and weight=2, and a second
banner with bannerID=302 and weight=10, the list would look like:

"301,301,302,302,302,302,302,302,302,302,302,302"

Then you could pull a random ID from this list and run the query.

>>> Elizabeth Walter <[EMAIL PROTECTED]> 03/05/02 01:14PM >>>
Hello-

I am developing a banner rotating tool and need some ideas on how to best
handle a requirement.  I have gotten the tool to a point where it displays
banners randomly- no problem.  Now what I need to do is give certain
banners
more "weight" than others:  some banners need to be displayed more
frequently than the rest.  The code that I have below gives equal weight
to
each banner; I need to find a way to give some banners more prevalence on
our pages.


        <cfset activeBanners=arrayNew(1)>

        <cfoutput query="qryActive">
                <cfset activeBanners[#qryActive.currentRow#] = "#id#">
        </cfoutput>

        <cfset rows = arrayLen(activeBanners)>

        <cfset randomId = randRange(1,#arrayLen(activeBanners)#)>

        <cfquery datasource="#dsn#" name="qryBanners">
        SELECT
                i.*,
                a.advert_name
        FROM
                images i, advertiser a
        WHERE
                i.id = #activeBanners[randomId]# and
                i.advert_id = a.advert_id
        </cfquery>


Any ideas?

Thanks in advance,
Elizabeth





______________________________________________________________________
Get Your Own Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation � $99/Month � Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to