Using posts for page commenting
Posts are extremely flexible, in this page we indicate how they can be used to create a moderated or unmoderated page commenting system. The example in question would be intended to work on an extranet/intranet where the commenting is from a logged in user. It would possible to create a commenting system on a public system but in such cases the comments would be anonymous.
The steps are as follows
- Create a post type that will collect all the information you want from your commenters
- Check that this can be populated via the createposts web service
- Create a form with the same field names as your post type
- Create a data island using searchposts that is filtered to show the comments from that page
- Add items 3 and 4 to a variable block so their easy to add to any page you want commenting on
- Add the variable block to the relevant pages
The above is a simple example, there would also be option via alternative searchposts data islands to provide listing of all page comments or all pages commented on by a specific user.
In more detail:
Create a post type ‘comments’, taking arguments for logged in users etc
These posts can be populated via a web service eg
We need to create a form that passes values to the webservice. Each of the form ‘name’ fields needs to be the same as the argument required by the webservice above. As you can see some of the hidden values can be automatically populated by magic words.
An example of the popup for the 'what do you think?' text area. As you can see it's name value is 'body' so that ultimately the value entered into this field will get passed through to the web service as the body argument,. There needs to be matching name value pairs from the form or the URL to match all the required arguments for the web service.
In the form properties section for the form above we pass the values to the createpost web service outlined in 2. This is done by ticking the 'Submit to Web Service or other external URL' box to reveal the dialog box shown below. The createpost URL as shown is entered into this.
As you can see some of the fields needed for the createpost web service can be hard-coded into the URL with the remaining ones drawn from whatever the user inputs in the form. Note the 'active=1' as this means that the post addition is not moderated. The web service defaults to moderated.
We can then embed this form in a page using the XML snippet below
<ENQUIRYFORM> <FORMID>6403</FORMID> </ENQUIRYFORM>
To get a commenting block as shown below
To then provide output (previously submitted comments) we add a data island using the filtering via the automatically passed in shortcuts ID of that page. That way all the page commenting post are in one location in admin but they are filtered via shortcutID no each page. We add this data island below the form and put it in a variable block so it can be easily added to lots of pages. In the DI below the ID argument is the posttypeID
<ENQUIRYFORM> <FORMID>6403</FORMID> </ENQUIRYFORM> <h3>Approved comments so far</h3> <xmlconsumer> <xmlsource url="http://helpcms.sitekit.net/Admin/Post/SearchPosts.aspx?ID=45&custom_ID=302748&orderby=startDate%20desc" allowedParameters="ID,custom_ID,orderby" ></xmlsource> <xslsource url="http://helpcms.sitekit.net/2013-layout/xsl/pagecomments.xsl"></xslsource> </xmlconsumer>
We could also provide a page/dataisland with all page comments aggregated on it or alternatively all pages commented on by user x.