Sites often permit visitors to leave comments - be they blog comments, visitor books or comments on Wiki pages.
Weceem supports a generic mechanism for visitors to create new content nodes via a form, filtered through the security policy.
This is, for example, how the default space implements comments on blogs. A widget is used to render a form to capture the comment fields and submit them to Weceem's content submission controller - where they are, if the security policy permits that kind of content at that URI, from that (anonymous) user - saved in an "unmoderated" status (see: security policy).
To allow users to submit content, you need to provide the data from the client browser - usually with a form that the user completes. You will usually do this inside a Widget node so that the code can be reused:
<g:hasErrors bean="${submittedContent}">
There were some errors on your submission, please check below
</g:hasErrors>
<wcm:submitContentForm parent="${parentContent}" type="org.weceem.content.WcmComment" success="${parentContent}">
<bean:require beanName="submittedContent" className="org.weceem.content.WcmComment"/>
<bean:field beanName="submittedContent" property="author" label="Your name"/>
<bean:field beanName="submittedContent" property="email"/>
<bean:input beanName="submittedContent" property="websiteUrl" label="Website URL"/>
<bean:input beanName="submittedContent" property="title"/>
<bean:field beanName="submittedContent" property="content" label="Your comment"/>
<input type="submit" class="button positive" value="Send comment"/>
</wcm:submitContentForm>
Here, three different Grails taglibs are being used to create the form:
The form will include a link to the content submission controller. This controller will save the content if it is valid, or return to the existing content with the "submittedContent" object populated with the previous data and any errors attached. Using the bean:* tags of the Grails Bean-Fields plugin is merely a convenience, but is very useful as it will display the validation errors associated with each field inline in the form.
If the submission succeeds - which requires the user to have permission to create that type of content under the specified parent in the repository - it will redirect the user to the content specified in the "success" attribute.
The content will be in the "unmoderated" status, until an administrator updates the status to Published.