Skip to content

Instantly share code, notes, and snippets.

@stevewithington
Created June 3, 2014 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevewithington/1d9e2939feccbc982285 to your computer and use it in GitHub Desktop.
Save stevewithington/1d9e2939feccbc982285 to your computer and use it in GitHub Desktop.
Mura CMS : How to set the Content Release Date automatically, if it's not filled in
<cfscript>
// Drop this function in your Site, Theme, or Plugin's eventHandler.cfc
public any function onBeforeContentSave($) {
// reference to the newBean
var newBean = arguments.$.event('newBean');
// reference to the original contentBean (in case you need it for anything)
var oldBean = arguments.$.event('contentBean');
// Check to see if the contentBean has a parent, and if so
// see if it's the 'News', check the releaseDate and populate if necessary
if (
newBean.hasParent()
&& newBean.getParent().getTitle() == 'News'
&& !Len(newBean.getValue('releaseDate'))
) {
newBean.setValue('releaseDate', Now());
}
}
</cfscript>
@sebgmc
Copy link

sebgmc commented Oct 1, 2014

Combined with this gist (https://gist.github.com/cameroncf/d774b8065559ddd8b861) perfect!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment