Custom Tag Help Please

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  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. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. 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...
    5. 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...
  3. #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

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139