CFModule varaiable passing

Posted on 2011-05-12
Medium Priority
Last Modified: 2013-12-24
I have looked on this site and so far have not been able to find a basic understanding of CFMODULE.

I have 2 pages:
CALLING PAGE contains <cfmodule name="mymodulename.index" var1="11111" var2="22222">

MODULE PAGE is calling for var1, but no varaiable name exists.

The basic connection between the CALLING and MODULE page is fine, but passing the variables just doesn't happen.  What am I missing here?
Question by:mopar003

Accepted Solution

sajayc earned 2000 total points
ID: 35750100

On the module page, how are you referencing the variable?
It should be #attributes.var1#

Post some code if this doesn't work.

Hope this helps.
LVL 52

Expert Comment

ID: 35751609
(no points ..)

Just to clarify, cfmodule is like using a custom tag.  Any variables passed to a custom tag (by name) are placed in the tag's "attributes" scope.   It's similar to how cffunction's work. Any values passed into a cffunction are placed in the "arguments" scope.

So inside the tag "var1" becomes #attributes.var1# and "var2" becomes #attributes.var1#.
<cfmodule name="mymodulename.index"

You can also use attributeCollection to pass in a bunch of arguments at once.

<cfset myArgs = structNew()>
<cfset myArgs.var1 = "11111">
<cfset myArgs.var2 = "22222">

<cfmodule name="mymodulename.index" attributeCollection="#myArgs#">


Author Closing Comment

ID: 35756633
Thats what I was missing.  Never called it by attributes tag.  Thank you.  I knew it would be a simple thing!

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question