This content has been marked as final. Show 6 replies
You want a custom tag to call itself? Why not use a loop instead?
Or, do you want to call another custom tag from a custom tag. In that case you send the attributes the same way you would from a normal template.
You could use the caller scope:
But as the nots there suggest, it would be generqally be considered better
practice to pass-in as attributes, any external values you wish to use in
the custom tag.
You might also want to take a look at the documentation for parent/child data exchange:
I am basically building a set of custom conditional tags. This is for a situation where <cfif> just will not work. I want to be able to nest them like the regular <cfif> tags. Each nested <cfif> adds it's structure into an attribute of it's parent tag. I have everything working; I have else if and else functionality, I can nest if tags in else if or else tags, and I can traverse and parse the entire set of tags and get the result I was expecting. The one thing I can't do is nest an if tag inside of another if tag, because the child tag can't seem to see the parent if they are the same tag. I use GetBaseTagData() to access the attributes of the parent tag, and like I said it works fine with an if tag nested in a if else or else tag. I can't use the CALLER scope, as that references the page that called the first custom tag, no matter how deeply nested I am. I'm so close to being finished, there has to be a way to do this. Thanks
> I can't use the
> CALLER scope, as that references the page that called the first custom tag, no
> matter how deeply nested I am.
I think you should test the advice, before you make assertions like this.
The CALLER scope refers to the variables scope of the template that called
the currently executing custom tag. If your calling stack is like this:
Then the situation is this:
1) In index.cfm: no caller scope.
2) In customTagA.cfm: caller scope references index.cfm's variables scope.
3) custoTagB.cfm: caller scope references customTagA.cfm's variables scope
(NOT index.cfm's one).
Similarly, if your calling stack is like this:
Then the caller scope in each customTag.cfm instance refers to the
variables scope of the file above it. The only caller scope that
references index.cfm's variables scope is the customTag instance marked
If I understand your requirement, this is what you want. This is why I
This is the code I use to write to the parent tag's attributes:
<cfif ListLen(ancestorList) GT 1 AND LCase(Left(ListGetAt(ancestorList,2),9)) EQ "cf_delay-">
....<cfset parentData = GetBaseTagData(ListGetAt(ancestorList,2))>
....<cfset parentData.ATTRIBUTES.nestedIf[ArrayLen(parentData.ATTRIBUTES.nestedIf) + 1] = thisTag>
The reason I can't use the CALLER scope is because I am not calling the nested tags from within the template of the parent custom tag. My tags are nested inside the opening and closing tags of the parent custom tag on the original template, like this:
Every time there is an <if> it writes to the containing tag's attributes. Sorry for the confusion