Professional Web Applications Themes

How to output Query results to base page form a customtag - Coldfusion - Advanced Techniques

Hello guys, I have creates a custom tag that happened to be called with an end tag (<cf_mytag>some content </cf_mytag>) Now I have a query inside the mytag page like this: <cfif thistag.executionmode is "end"> <cfquery datasource="test" name="name"> select * from test </cfquery> <cfset thistag.generatedcontent = ""> </cfif> Now I want to output the results in the base page like this: <cfoutput query="Name"> #test# - #id#<br> </cfoutput> Can you help me with how to output the query results to the base page? Thanks, Sam...

Sponsored Links
  1. #1

    Default How to output Query results to base page form a customtag

    Hello guys,



    I have creates a custom tag that happened to be called with an end tag
    (<cf_mytag>some content </cf_mytag>)



    Now I have a query inside the mytag page like this:



    <cfif thistag.executionmode is "end">



    <cfquery datasource="test" name="name">

    select * from test

    </cfquery>



    <cfset thistag.generatedcontent = "">



    </cfif>



    Now I want to output the results in the base page like this:



    <cfoutput query="Name">

    #test# - #id#<br>

    </cfoutput>



    Can you help me with how to output the query results to the base page?



    Thanks,

    Sam


    Sponsored Links
    Saman Guest

  2. #2

    Default Re: How to output Query results to base page form acustom tag

    Make your custom tag accept an attribute for a return variable name. Make sure
    you give it a default value. Then you return it to the calling page like this:

    <cfset rslt=evaluate("caller.#attributes.ReturnVariable# = name")>

    Use this syntax on your calling page
    <cf_mytag returnvariable="something">

    There may be other ways available, but this syntax works for us.


    Dan Guest

  3. #3

    Default Re: How to output Query results to base page form acustom tag

    Seems like a lot of ways to go with this one. You could...

    1) Have the custom tag output the query, and pass the "some content" as an
    attribute.
    2) Have the custom tag set a variable in the caller scope that the calling
    page uses to output the results
    3) Do as Dan suggested if you want the variable name in caller to by dynamic.

    BSterner Guest

  4. #4

    Default Re: How to output Query results to base page form acustom tag

    Thanks guys. it works great!
    i have a nother quection. going to ask in a nother post. need your help in that too :-)

    thanks again.
    sam
    Saman Guest

Similar Threads

  1. Question Is it possible to display the query results in a form
    By Nokia N93 in forum Brainstorming Area
    Replies: 0
    Last Post: December 1st, 04:38 PM
  2. Passing Query To the CustomTag
    By Stressed_Simon in forum Macromedia ColdFusion
    Replies: 2
    Last Post: July 21st, 02:22 PM
  3. Help with form results in query
    By Ken in forum ASP
    Replies: 4
    Last Post: September 29th, 07:45 PM
  4. search results output in form
    By Han in forum Microsoft Access
    Replies: 2
    Last Post: August 17th, 02: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
  •  

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