Last active
December 27, 2015 14:39
-
-
Save modmedia/7342350 to your computer and use it in GitHub Desktop.
Create a Mura content node from a Mura form
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
<!--- Drop this into your site eventhandler.cfc ---> | |
<cffunction name="onAfterFormSubmitSave" output="true"> | |
<cfif $.event('formid') EQ '{ID of the Mura form}'> | |
<!--- Get the form result ---> | |
<cfset formBean = $.event().getValue('formresult')> | |
<!--- Get a new content bean ---> | |
<cfset cBean = application.contentManager.getBean()> | |
<!--- Set the new node attributes ---> | |
<cfset cBean.setSiteID($.event('siteid'))> | |
<cfset cBean.setType('Page')> | |
<cfset cBean.setSubType('mySubtype')> | |
<cfset cBean.setTitle(formBean.TITLE)> | |
<!--- Set any extended attributes ---> | |
<cfset cBean.setExtAttribute1(formBean.VALUE1)> | |
<cfset cBean.setExtAttribute2(formBean.VALUE2)> | |
<!--- if your form has a file in it, set it as the associated image ---> | |
<cfset cBean.setFileID(formBean.FILE_ATTACHMENT)> | |
<!--- Set the content ID of where you want this new node to live under ---> | |
<cfset cBean.setParentID('{content ID}')> | |
<!--- Set whether it's displayed, approved, nav, etc ---> | |
<cfset cBean.setApproved(1)> | |
<cfset cBean.setDisplay(1)> | |
<cfset cBean.save()> | |
</cfif> | |
</cffunction> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Matt,
i tried the above gist in my event handler and it was showing syntax error
this gives me a syntax error.
thanks susan<cfif $.event('formid') EQ '{ID of the Mura form}'>
<!--- Get the form result struct--->
<cfset var formData= $.event('formresult')>