Last active
April 16, 2017 22:15
-
-
Save stevewithington/9137544 to your computer and use it in GitHub Desktop.
Mura CMS : This is an example of how to dynamically populate an extended attribute select menu/selectbox based on a Mura Content Collection / Local Index.
This file contains hidden or 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
<cfscript> | |
component extends="mura.cfobject" output="false" { | |
// Drop the methods below in your theme or site contentRenderer.cfc | |
// This example assumes you wish to populate the Label with the content Title, and the value stored would be the URL | |
// With the methods defined below, you should be able to add the following into your extended attribute fields: | |
// Option List: [mura]$.getSpeakersOptionList()[/mura] | |
// Option Label List: [mura]$.getSpeakersOptionLabelList()[/mura] | |
// SPEAKERS | |
// getSpeakersOptionList (value stored by Mura) | |
public any function getSpeakersOptionList() { | |
var it = getSpeakersfeed().getIterator(); | |
var item = ''; | |
var optionList = ''; | |
While(it.hasNext()) { | |
item = it.next(); | |
optionList = ListAppend(optionList, item.getURL(), '^'); | |
}; | |
return optionList; | |
} | |
// getSpeakersOptionLabelList (label displayed to User) | |
public any function getSpeakersOptionLabelList() { | |
var rs = getSpeakersFeed().getQuery(); | |
return ValueList(rs.title,'^'); | |
} | |
// getSpeakersFeed (assumes you have a pre-defined feed/content collection named 'Speakers') | |
public any function getSpeakersFeed(feedName='Speakers') { | |
return variables.$.getBean('feed').loadBy(name=arguments.feedName); | |
} | |
// @END Speakers | |
} | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This saved our lives! Thanks so much!