Created
February 27, 2014 17:08
-
-
Save stevewithington/9254460 to your computer and use it in GitHub Desktop.
Mura CMS : Example of how to get a list of Local Content Collections / Feeds to dynamically populate a select menu class extension.
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> | |
public any function getLocalFeeds() { | |
return variables.$.getBean('feedManager').getFeeds(siteid=variables.$.event('siteid'), type='local'); | |
} | |
public any function getLocalFeedNames() { | |
var rs = getLocalFeeds(); | |
return rs.getRecordcount() | |
? ValueList(rs.name, '^') | |
: 'No Content Collections Exist!'; | |
} | |
</cfscript> |
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
<attribute | |
name="feedList" | |
label="Listing Content Collection/Local Index Feed Name" | |
hint="Select the name of the Local Content Collection/Index to use" | |
type="selectbox" | |
defaultValue="[mura]ListFirst($.getLocalFeedNames(), '^')[/mura]" | |
required="false" | |
validation="" | |
regex="" | |
message="" | |
optionList="[mura]$.getLocalFeedNames()[/mura]" | |
optionLabelList="[mura]$.getLocalFeedNames()[/mura]" /> |
@alladinUK, you should be able to put the methods in either the site or theme contentRenderer.cfc
. Depending on which one you place the methods in, you may have to reload Mura in order for them to get picked up. If that doesn't work, let me know the full path to the file you're trying to place them in.
Hi Steve,
Thank you for your reply.
For some reason it was throwing the error I reported earlier even having done appreload. I've restarted Lucee and I am no longer getting an error and works as expected.
Thank you for your time.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Where are you supposed to put getLocalFeeds.cfm?
I'm trying to do the same, I've created extended attributes under site/Default class extensions do the dropdown can appear under "Site settibngs"
As I'm not sure where to put getLocalFeeds.cfm, I added the methods under contentRenderer.cfm
Unfortunately when I try to edit my site settings, I get an error in the console getLocalFeedNames is unidentified in Mura scope.
I don't think I should be adding it to contentRenderer.cfm, but I'm not sure where else to add it.
Hope you can point me in the right direction.
Thank you.