Instead of putting it in the application.cfc, why not put it in a new CFC which 
you can then call from each page? 

I personally would not put this in the application.cfc, but rather create a new 
CFC to put this in.


> I have this Huge chunk of code placed on some of my pages to create a 
> rotating banner. The thing is, I would like to place it on the 
> application.cfc to then call it from my page, so I don't have to 
> repeat it on every page where I want the banner to appear.
> 
> Here is the code:
> 
> <!--- Start Query Banner DB --->
> <cfquery datasource="advertisers" name="banner">
> select *
> from TopBnr_GDA3
> order by ID desc
> </cfquery>
> <!--- End Query Banner DB --->
> 
> <!--Now, it is time to take all your banners and shuffle them and pick 
> the magical banner to display. This next part will be documented fully 
> so you can see how the weighted system is accomplished.-->
> 
> <!--- Start Weighting and Rand Num. --->
> <!--- This starts your list for all the numbers to pick from --->
> <cfset prodlist="">
> <!--- Telling it to output the data your queried --->
> <cfoutput query="banner">
> <!--- Creating a counter --->
> <cfset x=1>
> <!--- Starting the loop --->
> <cfloop index="x" from="1" to="#banner_weight#">
> <!--- This added the banner ID to the list for every weight --->
> <cfset prodlist=listappend(prodlist,#id#)>
> <!--- Adding one to the counter --->
> <cfset x=x+1>
> <!--- The end of the looping --->
> </cfloop>
> <!--- End of the data query --->
> </cfoutput>
> <!--- This startment pulls a random number from 1 to the length of the 
> list --->
> <cfset magicnumb=randrange(1,listlen(prodlist))>
> <!--- This one will pull the banner ID out from the random number 
> point --->
> <cfset magicnum=listgetat(prodlist,magicnumb)>
> <!--- End Weighting and Rand Num. --->
> 
> <!--Almost there. The weighting and random part is done now to add one 
> view to the Banner_views variable of the particular banner.-->
> 
> <!--- This queries the specific banner --->
> <cfquery datasource="advertisers" name="views">
> select *
> from TopBnr_GDA3
> where id = #magicnum#
> </cfquery>
> <!--- start Adds 1 to view --->
> <cfoutput query="views">
> <CFSET add = #ban_views# + 1>
> <CFQUERY datasource="advertisers" name="UpdateView">
> UPDATE TopBnr_GDA3 Set ban_views = #add# where ID = #id#
> </cfquery>
> </cfoutput>
> <!--- End Adds 1 to view --->
> 
> <!--This next part will display the banner. -->
> 
> <cfoutput query="views">
> <A HREF="redirect.cfm?ID=#magicnum#" TARGET="_blank">
> <IMG SRC="#banner_pic#" alt="#banner_alt#"></A>
> </cfoutput>
> 
> Thanks for the Help!
> 
> Frank V. 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Newbie/message.cfm/messageid:3771
Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15

Reply via email to