What you will need
- Two Lists
- SharePoint Designer
- Basic knowledge of HTML
I’ll assume you already have a list setup on which you want to allow users to comment. For this example I will use a standard Announcements list.
So the first thing we need to do is create a list to hold our comments. I just used the following columns:
- Post (lookup to main list’s ‘Title’ column)
In the main list you will need to add a column that points back to the comments list.
- Go to the list settings page and click ‘Create Column’
- Name the column ‘Comments‘ (the name does not really matter. Set the type to ‘Lookup‘
- The lookup should get information from the comments list you created. The column should be set to the lookup column in the comments list. See the screenshot below. This column will show us the number of comments each item in our list has.
Ok so now that we have the two lists pointing to each other we need to show the comments on a page with our list item.
- Add a couple of items to each list just for testing purposes.
- Create a blank web part page.
- Add a data view web part to the page to display the Annoucements list.
- Create a parameter on the dataview named item and set it to get the variable from the query string.
Note : Whatever link user click to get to this page will need to pass the item ID as a variable in the query string in order for this solution to work. In my example I am passing the ID in the ‘item’ variable but you can use whatever you want.
Adjust the filter settings so that the list is filtered using the parameter that has been created. You can test to verify this is working by putting “?item=1” and the end of the url and the list item with an ID of 1 should be displayed.
- Add a web part to the page below the data view to display your comments list. Create a web part connection to filter the comments list based on the Title of the Annoucement list item.
Test the page and you should see one annoucement and the related comment. In my next post we will create a form so that users can create new comments.