Answered
Is there a way to test for the first calling of a function?
Hi,
I created a function (using other functions I created) to build a dynamic hierarchy tree menu based on parentID and itemID etc etc - I'm sure you're familiar with this concept. It works great, and there's no problem there.
However, I do this all by building it into a string, then dumping it on the page. Yet again, this all works fine. However, because the function gets called recursively, my class, class="tree" gets repeat accross every occurance of the opening UL tag.
I only want this class to be applied to the first UL, but because this is recursive, I'm not sure of a way to detect if the function is being called for the first time or 5th time, etc. I want to say something like:
<cfif myFunction is being called the first time>
add the class
<cfelse>
don't add the class
</cfif>
Please see my code attached. It is fully working. Please don't worry about what all the other functions do etc, they are working fine, but I need a way or variable to test against.
Any ideas?
Many thanks,
Michael.
I created a function (using other functions I created) to build a dynamic hierarchy tree menu based on parentID and itemID etc etc - I'm sure you're familiar with this concept. It works great, and there's no problem there.
However, I do this all by building it into a string, then dumping it on the page. Yet again, this all works fine. However, because the function gets called recursively, my class, class="tree" gets repeat accross every occurance of the opening UL tag.
I only want this class to be applied to the first UL, but because this is recursive, I'm not sure of a way to detect if the function is being called for the first time or 5th time, etc. I want to say something like:
<cfif myFunction is being called the first time>
add the class
<cfelse>
don't add the class
</cfif>
Please see my code attached. It is fully working. Please don't worry about what all the other functions do etc, they are working fine, but I need a way or variable to test against.
Any ideas?
Many thanks,
Michael.
