Created
March 25, 2014 01:00
-
-
Save bennadel/9753268 to your computer and use it in GitHub Desktop.
I Wish: ColdFusion Custom Tag Query Looping
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfswitch expression="#THISTAG.ExecutionMode#"> | |
<cfcase value="Start"> | |
<!--- Param the query name. ---> | |
<cfparam | |
name="ATTRIBUTES.Query" | |
type="variablename" | |
/> | |
<!--- Default the loop index. ---> | |
<cfset VARIABLES.LoopIndex = 1 /> | |
</cfcase> | |
<cfcase value="End"> | |
<!--- Check to see if loop index is not too high. ---> | |
<cfif (VARIABLES.LoopIndex LT CALLER[ ATTRIBUTES.Query ].RecordCount)> | |
<!--- Increment the index. ---> | |
<cfset VARIABLES.LoopIndex++ /> | |
<!--- Loop over *only* the selected row. ---> | |
<cfloop | |
query="CALLER.#ATTRIBUTES.Query#" | |
startrow="#VARIABLES.LoopIndex#" | |
endrow="#VARIABLES.LoopIndex#"> | |
<!--- Run the body of the tag again. ---> | |
<cfexit method="loop" /> | |
</cfloop> | |
</cfif> | |
</cfcase> | |
</cfswitch> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment