Well, even though there's some issue of the best way to pull this off, I am
having another problem. I am trying to create a custom tag that will out put
user data into x number of columns with the attributes being QueryName and
NumberOfColumns. My problem now is that I want to be able to mix plain text
or html with variables. I've gotten it to do one or the other, if I use
#evaluate(localcontent)# in the code below, I can output variables from the
query that were passed, if I don't use evaluate, I can get text, but the
variables show up as #variable#. Anyone know a way around this?


<!--- da code --->
<cfswitch expression="#ThisTag.ExecutionMode#">
<cfcase value="Start">
        <cfif NOT ThisTag.HasEndTag>
                <cfabort showerror="This tag needs an end tag">         
        </cfif>
        <cfif NOT IsDefined("Attributes.QueryName")>
                <cfabort showerror="The attribute QUERYNAME is required to
run this tag">  
        </cfif>
        <cfparam  name="Attributes.NumberOfColumns" default="3">
</cfcase>
        
<cfcase value="End">
<cfset LocalContent=ThisTag.GeneratedContent>
                
<table border="0" cellpadding="2" cellpsacing="2" width="100%">

<cfoutput query="#LocalQuery#">
<cfif currentrow mod attributes.NumberOfColumns is 1>
        <tr>
</cfif>
        <td align="right"> #LocalContent# </td>
<cfif currentrow mod attributes.NumberOfColumns is 0>
        </tr>
</cfif>
</cfoutput>

<cfif LocalQuery.recordcount mod NumberOfColumns is not 0>
        <cfset variables.ColsLeft = attributes.NumberOfColumns -
(LocalQuery.recordcount mod attributes.NumberOfColumns)>
        <cfloop from = "1" to = "#variables.ColsLeft#" index = "i">
                <td>&nbsp;</td>
        </cfloop>
        </tr>
</cfif>
</table>
</cfcase>
</cfswitch>




-----Original Message-----
From: Andre Mohamed [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 14, 2003 12:41 PM
To: CF-Talk
Subject: RE: Caller access to query


Some people (not necessarily me) believe doing this is better:

<cf_mytag theQuery="#myQuery#"/>

i.e. passing the query by value and hence avoiding breaking any kind of
encapsulation.

Inside the tag you refer to the query in the normal way e.g.

<cfset localQuery = attributes.theQuery>

or just:

<cfloop query="attributes.theQuery">
...
</cfloop>

However, if you follow the syntax of native ColdFusion tags then the
analogous approach is to do what you have opted to do. E.g.

<cf_mytag theQuery="myQuery"/>

Inside the tag:

<cfset localQuery = caller[attributes.theQuery]/>


Andr�

-----Original Message-----
From: Venable, John [mailto:[EMAIL PROTECTED] 
Sent: 13 August 2003 19:13
To: CF-Talk
Subject: RE: Caller access to query

Thanks everyone, I was passing the queryname in as an attribute and
<cfset
_localQuery = Evaluate("Caller." + Attributes.query) /> was just what I
needed. I had to change the + to & for concatenation though.

Thanks

John Venable

-----Original Message-----
From: webguy [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 13, 2003 12:58 PM
To: CF-Talk
Subject: RE: Caller access to query


If myquery is the query on your page then in your custom tag

<cfset _localQuery = Caller.myquery />

Better is to pass the query in the tag

        <cf_mytag query="myquery" />

and in the tag

        <cfset _localQuery = Evaluate("Caller." + Attributes.query) />


WG

-----Original Message-----
From: Venable, John [mailto:[EMAIL PROTECTED]
Sent: 13 August 2003 17:45
To: CF-Talk
Subject: Caller access to query


Is there a way to access an existing query recordset from a custom tag
called on the page? So if I have a query in a page, and I call a custom
tag,
can i use the query data through come sort of caller scope object? I
can't
seem to make it work.

Thanks

John Venable




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. 
http://www.fusionauthority.com/ads.cfm

Reply via email to