Skip to content

Instantly share code, notes, and snippets.

@stevewithington
Created February 27, 2014 17:08
Show Gist options
  • Save stevewithington/9254460 to your computer and use it in GitHub Desktop.
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.
<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>
<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]" />
@umbraesoulsbane
Copy link

Steve,

I am not sure if this is expected or something that needs some attention in the core (6.2.6389). However, this code did not work for me with Oracle. It appears the value of type is "Local", so with a case sensitive DB using your code as "local" returns nothing.

For this code (getLocalFeeds()) to work on a case sensitive DB it needs to be:
variables.$.getBean('feedManager').getFeeds(siteid=variables.$.event('siteid'), type='Local');

Thanks for the great GISTs BTW!

@alladinUK
Copy link

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.

@stevewithington
Copy link
Author

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

@alladinUK
Copy link

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