Search code examples
coldfusionmura

getting a custom attribute from the current item in ColdFusion?


Disclaimer, I'm a ColdFusion newbie...

I'm using Mura CMS 6, and I've got a question with regards to accessing a custom attribute.

My contentRenderer.cfc file has code for a Bootstrap Carousel. I'd like to be able to output the contents of a custom attribute on the file that the carousel is using, but I'm not entirely sure how to do that.

My custom attribute is named 'imageLink', but I have no idea how to get the current context to be able to output the contents of this attribute to the screen.

The following code is the code for the carousel (I didn't write it)

        <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>

How can I access the current context to output that attribute?


Solution

  • Here are the docs on how to display them.

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

    It looks like you looping through a collection of content so I believe this would work.

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