> Is there a way to dynamically define the parameters to a CFMODULE
> tag?
>
> For instance, lets say I have a variable called "strParamName".
> If the value of this variable is "ProductName" then I want my
> CFMODULE to be executed as if I hardcoded it like so:
> <CFMODULE TEMPLATE="qryMyQuery.cfm"
>     ProductName = "someval">
>
> However, if the variable has the value "ProductSKU" then I
> want the CFMODULE to be executed as if I hardcoded it like so:
> <CFMODULE TEMPLATE="qryMyQuery.cfm"
>     ProductSKU = "someval">
>
> In other words, I want to do something like:
> <CFMODULE TEMPLATE="qryMyQuery.cfm"
>     #strParamName# = "someval"> (obviously this exact
> approach won't work)
>
> Exactly WHY I need this is a little complicated. I *could*
> move the logic for this into the module itself, but I'd like
> to do it like I outlined above if at all possible. Does anyone
> have any ideas?

There are a couple of ways you can achieve this.

One way is to simply pass in the name of the variable, and within the custom
tag, use the Caller scope to retrieve the value of the variable. So, using
your example, you might have a custom tag call like this:

<cfset ProductName = "FooBar">
<cfmodule template="qryMyQuery.cfm" vartouse="ProductName">

Then, within your custom tag, you could have something like this:

<cfset rs = SetVariable(Attributes.vartouse, Evaluate("Caller." &
Attributes.vartouse))>

This would create a local variable within the custom tag called ProductName
with the value of "FooBar".

Another way would be to simply pass whatever you want to the custom tag, and
within the custom tag, to loop through the Attributes scope.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444

------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to