CFModule varaiable passing

Posted on 2011-05-12
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
    LVL 3

    Accepted Solution


    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 51

    Expert Comment

    (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#">

    LVL 1

    Author Closing Comment

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
    Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now