Created
June 3, 2014 10:04
-
-
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
This file contains 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> | |
// 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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Combined with this gist (https://gist.github.com/cameroncf/d774b8065559ddd8b861) perfect!