Last active
August 29, 2015 14:05
-
-
Save davidpanzarella/f002efe0208cdbf16a10 to your computer and use it in GitHub Desktop.
Remove any empty grouping tags from the Current Params
This file contains 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
<!--- start: scrub empty param relationships ---> | |
<cffunction name="scrubEmptyParamRelationships" output="false" returntype="query"> | |
<cfargument name="query" required="true"> | |
<cfset local.openList = "" /> | |
<cfset local.closeList = "" /> | |
<cfset local.removeList = "" /> | |
<cfloop query="arguments.query"> | |
<cfif relationship eq "andOpenGrouping"> | |
<cfset local.openList = listAppend(local.openList,param) /> | |
<cfelseif relationship eq "closeGrouping"> | |
<cfset local.closeList = listAppend(local.closeList,param) /> | |
</cfif> | |
</cfloop> | |
<cfloop list="#local.openList#" index="openIndex"> | |
<cfloop list="#local.closeList#" index="closeIndex"> | |
<cfif (closeIndex - openIndex) eq 1 > | |
<cfset local.removeList = listAppend(local.removeList,openIndex) /> | |
<cfset local.removeList = listAppend(local.removeList,closeIndex) /> | |
</cfif> | |
</cfloop> | |
</cfloop> | |
<cfset local.removeList = listSort(local.removeList,"numeric","desc") /> | |
<cfloop list="#local.removeList#" index="removeIndex"> | |
<cfset arguments.query.deleteRow(removeIndex) /> | |
</cfloop> | |
<cfreturn arguments.query> | |
</cffunction> | |
<!--- end: scrub empty param relationships ---> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment