从ColdFusion中的当前项获取自定义属性?

时间:2016-11-28 14:43:59

标签: coldfusion mura

免责声明,我是ColdFusion的新手...

我正在使用Mura CMS 6,我对访问自定义属性有疑问。

我的contentRenderer.cfc文件包含Bootstrap Carousel的代码。我希望能够在轮播使用的文件上输出自定义属性的内容,但我不完全确定如何做到这一点。

我的自定义属性名为'imageLink',但我不知道如何让当前上下文能够将此属性的内容输出到屏幕。

以下代码是轮播的代码(我没有写)

        <cfsavecontent variable="local.str"><cfoutput>
        <!--- BEGIN: Bootstrap Carousel --->
        <!--- IMPORTANT: This will only output items that have associated images --->
        <cfset local.feed = variables.$.getBean('feed').loadBy(name=arguments.feedName)>
        <cfset local.iterator = local.feed.getIterator()>
        <cfif local.feed.getIsNew()>
            <div class="container">
                <div class="alert alert-info alert-block">
                    <button type="button" class="close" data-dismiss="alert"><i class="fa fa-remove"></i></button>
                    <h4>Ooops!</h4>
                    The <strong>#HTMLEditFormat(arguments.feedName)#</strong> Content Collection/Local Index does not exist.
                </div>
            </div>
        <cfelseif local.iterator.hasNext()>
            <div id="#arguments.cssID#" class="carousel slide" data-interval="#arguments.interval#">

                <!--- Indicators --->
                <cfif arguments.showIndicators>
                    <ol class="carousel-indicators">
                        <cfset local.iterator.reset()>
                        <cfset local.idx = 0>
                        <cfloop condition="local.iterator.hasNext()">
                            <cfset local.item=iterator.next()>
                            <cfif ListFindNoCase('jpg,jpeg,gif,png', ListLast(local.item.getImageURL(), '.'))>
                                <li data-target="###arguments.cssID#" data-slide-to="#idx#" class="<cfif local.idx eq 0>active</cfif>"></li>
                                <cfset local.idx++>
                            </cfif>
                        </cfloop>
                    </ol>
                </cfif>

                <!--- Wrapper for slides --->
                <div class="carousel-inner" role="listbox">
                    <cfset local.iterator.reset()>
                    <cfset local.idx = 0>
                    <cfloop condition="local.iterator.hasNext()">
                        <cfset local.item=iterator.next()>
                        <cfif ListFindNoCase('jpg,jpeg,gif,png', ListLast(local.item.getImageURL(), '.'))>
                            <div class="item<cfif local.idx eq 0> active</cfif>">
                                <img src="#local.item.getImageURL(argumentCollection=local.imageArgs)#" alt="#HTMLEditFormat(local.item.getTitle())#">
                                <cfif arguments.showCaption>
                                    <div class="container">
                                        <div class="carousel-caption">
                                            <h2><a href="#local.item.getURL()#" title="Click to view the news story">#HTMLEditFormat(local.item.getTitle())#</a></h2>
                    #local.item.getTitle()#
                                        <!--    <p><a class="btn btn-larg btn-primary" href="#local.item.getURL()#">Read More</a></p>-->
                                        </div>
                                    </div>
                                </cfif>
                            </div>
                            <cfset local.idx++>
                        </cfif>
                    </cfloop>
                </div>

                <cfif local.idx>
                    <!--- Controls --->
                    <cfif local.idx gt 1>
                        <a class="left carousel-control" href="###arguments.cssID#" data-slide="prev" role="button">
            <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
            <span class="sr-only">Previous</span>
          </a>
                        <a class="right carousel-control" href="###arguments.cssID#" data-slide="next" role="button">
            <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
            <span class="sr-only">Next</span>
          </a>
                        <!--- AutoStart --->
                        <cfif arguments.autoStart>
                            <script>jQuery(document).ready(function($){$('###arguments.cssID#').carousel({interval:#arguments.interval#});});</script>
                        </cfif>
                    </cfif>
                <cfelse>
                    <div class="alert alert-info alert-block">
                        <button type="button" class="close" data-dismiss="alert"><i class="fa fa-remove"></i></button>
                        <h4>Oh snap!</h4>
                        Your feed has no items <em>with images</em>.
                    </div>
                </cfif>
            </div>
        <cfelse>
            <div class="alert alert-info alert-block">
                <button type="button" class="close" data-dismiss="alert"><i class="fa fa-remove"></i></button>
                <h4>Heads up!</h4>
                Your feed has no items.
            </div>
        </cfif>
        <!--- // END: Bootstrap Carousel --->
    </cfoutput></cfsavecontent>

如何访问当前上下文以输出该属性?

2 个答案:

答案 0 :(得分:2)

以下是有关如何显示它们的文档。

http://docs.getmura.com/v6/back-end/class-extension-manager/displaying-extended-attributes/

看起来你循环浏览了一系列内容,所以我相信这会有用。

#local.item.get("imageLink")#

答案 1 :(得分:0)

假设您正在使用cfloop并在行

之后工作
<cfset local.item=iterator.next()>

您可以使用

获取自定义imageLink值
#local.item.getImageLink()#

#local.item.getValue('imageLink')#