Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
Bill #1
Custom Tag Help Please
I have this tag. All works great except I have 3 of them on the page. They
do display at random but they display the same banner at the same time. I
need them to display seperate of each other but I figure there must be a way
of doing this without create 3 seperate tags. Here's the tag and beneath
this is the template that I call in an include statement.
<cfsetting enablecfoutputonly="Yes">
<cfparam name="attributes.action" default="display">
<cfswitch expression="#attributes.action#">
<cfcase value="display">
<!---get all the Thumbids------->
<cfquery name="getThumbIDs" datasource="#dns#">
SELECT ThumbID FROM ThumbAds
</cfquery>
<!----choose a random Thumb from known ids ------->
<cfset VARIABLES.RandomID = RandRange(1, getThumbIDs.RecordCount)>
<cfset VARIABLES.thisThumbID = ListGetAt((ValueList(getThumbIDs.ThumbID)),
VARIABLES.RandomID)>
<!----Get a Thumb ad with that ID --->
<cfquery name="getOneThumb" datasource="#dns#">
SELECT ThumbID, ImagePath, AltText, WebsiteURL FROM ThumbAds WHERE ThumbID
= #VARIABLES.thisThumbID#
</cfquery>
<!---return ad to caller for display------->
<cfscript>
caller.strThumb = StructNew();
caller.strThumb.ThumbID = getOneThumb.ThumbID;
caller.strThumb.ImagePath = getOneThumb.ImagePath;
caller.strThumb.AltText = getOneThumb.AltText;
caller.strThumb.WebsiteURL = getOneThumb.WebsiteURL;
</cfscript>
<!----update times displayed------->
<cfquery name="UpdateThumbs" datasource="#dns#">
UPDATE ThumbAds SET TimesDisplayed = TimesDisplayed + 1 WHERE ThumbID =
#VARIABLES.thisThumbID#
</cfquery>
</cfcase>
<cfcase value="click">
<!----update click thrus. you must make sure
database does not have NULL values for these columns,
or it won't update------->
<cfquery name="UpdateThumbs" datasource="#dns#">
UPDATE ThumbAds SET ClickThrus = ClickThrus + 1 WHERE ThumbID =
#URL.ThumbID#
</cfquery>
<!----and redirect------->
<cflocation url="#URL.thisURL#">
<cfabort>
</cfcase>
</cfswitch>
<cfsetting enablecfoutputonly="No">
******************* TAG END
Template called for in Include
<!---show thumb ad------->
<cfoutput>
<a
href="/index.cfm?AdAction=Click&thisURL=#strThumb.Website URL#&ThumbID=#strThumb.ThumbID#"
target="_blank">
<img src="/modules/ads/Thumbs/#strThumb.ImagePath#" alt="#strThumb.AltText#"
title="#strThumb.AltText#" width="156" height="41" border="0"></a>
</cfoutput>
Bill Guest
-
Update Custom Collection that is bound to DataGrid made up of Custom COlumns
I recieved some very useful help from Steven Cheng in an earlier post in this group entitled 'Dynamically create datagrid columns' and am now... -
How to assign a custom principal with a custom soap extension
I have created a custom soap extension. What I need to do next is assign my own custom principal to the current request context so that the... -
Keep custom property-value in custom rendered control
Hi there, here's the thing I have a custom control (rendered) with a label, textbox and some validators. I use that for entering a birthdate, to... -
Custom TextBox with custom attributes and properties question
I have an webform that has a datarepeater on it. In that repeater I'm binding some data and I have put a textbox control in there. On the... -
Custom Component and Custom Textbox binding
Hi, I am trying to accomplish the following. Here is what I want to do: 1. Drop a custom business object component onto the design surface... -
SafariTECH #2
Re: Custom Tag Help Please
Random numbers really are not random, they follow a pattern unless pre-seeded
with different numbers to start with.
I suspectteh reason that you see the 3 same ads is because even though the tag
is running in 3 locations, it is processing at the exact same time and uses the
same seed sequence due to that fact.
Lookup Randomize for some ideas
In MX7, you should set the algorithm variable to SHA1PRNG rather than using
the default for a better possible mixed result.
I think that will better the chances for different ads to appear from the same
tag
SafariTECH Guest



Reply With Quote

