I want to spit out slightly different html based on a filter condition passed to cfdirectory.
Here is my cfml:
<cfdirectory
directory="#dirName#"
name="fileList"
action="list"
type="file"
filter="*.jpg|*.jpeg|*.png|*.gif|*.mp4"
>
<ul id="content">
<cfoutput>
<cfloop query="fileList">
<cfif filter NEQ '*.mp4'> // I guess this is not possible and is throwing the error
<li class="content image">
<img src="img/#name#" />
</li>
</cfif>
<cfelse>
<li class="video image">
<video controls="controls">
<source src="img/#name#" type="video/mp4">
</video>
</li>
</cfif>
</cfloop>
</cfoutput>
</ul>
I presume that I cannot simply access the filter
inside the cfif
, but I am not sure how to skin it. Does it need to be stored in a variable outside of the loop?
Any help much appreciated
Lets take this step by step
More details
fileList.name
means: We want to look atname
. But not just any name that could exist in any scope. We want name that is associated withfileList
listLast()
means take the string variable, separate it by commas and tell me what the last item is. Return that as a string.listLast(..., '.')
You know that part about commas, yeah let's use periods instead. In other words, what is the last part of the file name after the last.
.If that is not mp4, then ...