I was about to send this question, but I figured out some ways to do it.
I'm posted it because I'd still like some feedback and the info. might
useful to some folks.

My solution is below the original mail....

---------------------- original mail --------------------------

I've having a Friday moment, Question about nested tags & scope.

( eg code below)

I want to share a function lib. so that it is available across nested tags.

If I include the lib in testmyTag.cfm, its not available to all the tags
If I include it in the parent tag it's not available in the child tag.
If I include it in the both tags it breaks, because the functions are
included twice.

I wonder if

<cfset tagdata = getbasetagdata("CF_MYTAGONE")>
        <cfoutput>
        #tagdata.test()#
        </cfoutput>

will work?  I'll try that. Right that does work but it sort removes that
usefullness of the function lib. :-(
How chould I do this ? thanks Justin


[tag directory]

mytagone.cfm
        <cfinclude template="mytaglib.cfm">
        <cfoutput>
                In mytagone #test()#
        </cfoutput>

mytagtwo.cfm
        <cfoutput>
                In mytagtwo #test()#
        </cfoutput>

mytaglib.cfm
        function Test()
        {
                return "test function"  ;
        }


[www directory]

testmyTag.cfm

        <cf_mytagone>
                <cf_mytagtwo />
        </cf_mytagone>


---------------------my current solution ----------------------------------


I think the best way is either

        a) include the lib in the calling page , and called the functions like so
        caller.functionname(a,b,c);

or

        b) include the file in the first tag and call is like so

        <cfset ParentTag = ListLast(getbasetaglist())>
        <cfset ParentTagScope = getbasetagdata(ParentTag)>

        ParentTagScope.functionname(a,b,c);

Its not perfect, because the lib. was meant make working with nested tags
easier :-)


--------------------------------------------------------

Hope that is clear !


-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

Reply via email to