Skip to the content

In my previous blog I explained how I setup a simple noticeboard using Umbraco Forms but it has a flaw, your users can't reply to the post. 

Don't worry! This can be setup without too much hassle and yes, it's still using Umbraco Forms! 

You need a new Document Type for the replies, the reason for not just using the Noticeboard post Document Type is because you don't need everything in this Document Type that you had in the Noticeboard Post Document Type.

 
You don't really need a subject, you don't need a summary, really all you need is 'reply content' and the author's name. 

The Reply Document type has 2 properties setup, a Name which is just a textstring and a Content property which is a textarea and could have the RTE frontend setup on it the same as I demo'd in my previous blog.

With a new Reply Document Type setup you can now map a new Form for your replies. So you have 2 forms, one for the main noticeboard posts and one for replies.

The reason for 2 separate forms is so you can have a new workflow for the comments. Below you will see the basic workflow setup for the Reply form.

Note that the 'Where to save' value is set to $current. What this allows us to do is attach the reply to the current noticeboard post. By having a separate form you can also enable or disable instant publish for comments. You may wish to moderate replies before they can be posted on your site.

Now the comment form is setup, I need to display it under the noticeboard post, for this I did a bit of hardcoding which I'm never a fan of but in this case it was a proof of concept and in a future release I'd change the code. 

On the Noticeboard Post Document Type I added:

@Umbraco.RenderMacro("renderUmbracoForm", new { FormGuid = "53b20d02-2154-4519-8b96-a16cce4ac366" })

To get the FormGuid, I go to the Forms section in the backoffice, click on the form you want to use and you will see the Guid in the address bar. 

This code will display the comment form at the bottom of the noticeboard post so that a user can now reply and because we set the `Where to save` property as $current, the comment is saved as a child of that specific noticeboard post. 

The node name maybe isn't the most user friendly but it shows that you can have replies posted and associated with the original noticeboard post. 

As always, I hope you find this useful and if you have any comments or questions, catch me on Twitter :) 

About the author

Owain

Owain

Owain is an Umbraco MVP, an Umbraco certified master and works on Umbraco projects on a daily basis. When not coding, he enjoys running, spending time with his wife and building lego! 

He is also a GitKraken ambassador and helps look after the H5YR.com website.

comments powered by Disqus

Where to find Owain

Twitter: @ScottishCoder
Linkedin: Owain Williams
Our: Our Umbaco