SELECT ThumbID FROM ThumbAds SELECT ThumbID, ImagePath, AltText, WebsiteURL FROM ThumbAds WHERE ThumbID = #VARIABLES.thisThumbID# caller.strThumb = StructNew(); caller.strThumb.ThumbID = getOneThumb.ThumbID; caller.strThumb.ImagePath = getOneThumb.ImagePath; caller.strThumb.AltText = getOneThumb.AltText; caller.strThumb.WebsiteURL = getOneThumb.WebsiteURL; UPDATE ThumbAds SET TimesDisplayed = TimesDisplayed + 1 WHERE ThumbID = #VARIABLES.thisThumbID# UPDATE ThumbAds SET ClickThrus = ClickThrus + 1 WHERE ThumbID = #URL.ThumbID# ******************* TAG END Template called for in Include #strThumb.AltText# [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => Bill [ip] => bill.betournay [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 1 [islastshown] => [isfirstshown] => 1 [attachments] => [allattachments] => ) --> Custom Tag Help Please - Coldfusion - Advanced Techniques

Custom Tag Help Please - Coldfusion - Advanced Techniques

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 ...

  1. #1

    Default 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

  2. #2

    Default 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

Similar Threads

  1. Update Custom Collection that is bound to DataGrid made up of Custom COlumns
    By Terry Holland in forum ASP.NET Data Grid Control
    Replies: 9
    Last Post: October 28th, 06:20 AM
  2. How to assign a custom principal with a custom soap extension
    By Michael in forum ASP.NET Web Services
    Replies: 3
    Last Post: May 12th, 04:20 PM
  3. Keep custom property-value in custom rendered control
    By Rob Joosen in forum ASP.NET Building Controls
    Replies: 0
    Last Post: May 12th, 11:56 AM
  4. Replies: 1
    Last Post: March 1st, 02:01 PM
  5. Binding to a Custom Component from a Custom Control
    By John in forum ASP.NET Building Controls
    Replies: 2
    Last Post: October 1st, 06:48 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •