html - cfdirectory 根据过滤器输出不同的 html

标签 html coldfusion cfml cfloop cfdirectory

我想根据传递给 cfdirectory 的过滤条件吐出略有不同的 html。

这是我的 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>

我想我不能简单地访问 cfif 中的 filter,但我不确定如何给它设置皮肤。是否需要存储在循环外的变量中?

非常感谢任何帮助

最佳答案

您可以简单地执行以下操作。

<cfif listLast(fileList.name, '.') NEQ 'mp4'>

关于html - cfdirectory 根据过滤器输出不同的 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61940140/

相关文章:

CF18 中的 XmlSearch() 函数未返回预期结果?

html - 使用 Mat-Table-Exporter 时找不到属性 'exporter'

html - 网站标题 Logo 图像不清晰

javascript - javascript中的跨浏览器缩放机制

javascript - 在 ColdFusion 中获取页面位置

javascript - 使用JavaScript 巧妙处理ColdFusion 9 序列化的查询数据?

javascript - 如何从 coldfusion cfc 页面获取返回变量?

Railo 服务器将加号 (+) 转换为空格

javascript - Windows 8 应用程序 iframe 尝试访问 Intranet 上的页面内容

coldfusion - 使用 cfscript new StoredProc() 时如何获取存储过程的结果