comment-large.jpg

Comment all you want

By Liam Coltman posted on 08 Sep 2011

What is it?

An extension of the nested asset listing functionality which allows users of your website to comment and rate content. Useful for things like blogs, article reviews, etc.

Assets used: Asset Builder, Asset Listing, Paint Layout

Below is an overview of how the components work together;

Paint layout with nested asset listing and asset builder 

How do I do it?

Configure the asset listing

  1. Make an asset listing and give it an appropriate name
  2. Acquire the locks and from the Asset Types to List drop down select Comment
  3. Select Live from the Asset Statuses to List (TIP: You can speed up your asset listings by specifying asset statuses to list. This is also a good area to double check if comments aren't being displayed as you expected.)
  4. Select the Root Node.  For this example you need to select the area of the tree that the dynamic listing will be used under, so the site asset for your website is a good location. (TIP: You can use more than one root node and reuse the comment listing asset across several sites.  You will only see content that is directly under the page the user is currently viewing)
    Set root node screenshot
  5. Set Direct Links only to Yes. This will prevent the listing from looking at anything other than the children of the page you are viewing
  6. Leave the Customise No Results Bodycopy set to Yes. This will allow you to set a different message to encourage people to comment on the asset if there are none
  7. Change the Parameter to Replacement Root node for the listing (must be a child of the static root node) and change the Source to Current Asset
    Replacement root node screenshot
  8. Click the Commit button

Create an Asset Builder

  1. Create a new Asset Builder and give it an appropriate name
  2. Acquire the locks and change the Asset Types to Create to Comment
  3. Leave the create status as Under Construction, it might be a good idea to approve the comments before they go live to stop any naughty messages from being posted
  4. If you have created a Metadata Schema for these assets you should apply that now however it is not necessary
  5. Leave Ignore Permissions set to Yes
  6. Commit your changes then navigate to the Create Location screen via the dropdown in the top right corner
  7. Change the Additional Location Data Sources Parameter to Additional Create Locations and set Source to Current Asset. This forces the comments to be created as children of the asset the Comment Builder is located on not under the builder itself
    Create location screenshot
  8. Change the Default Link Type to Type 2 which will prevent comments from appearing in any navigation menus
  9. Set the Permitted Tree Locations to where you want the comments to be made.  Just like the asset listing these should be set as high as you need them and can include several different sites for reuse.
  10. Under Permitted Asset Types set the different types that you think the comments will be created under. Normally these are Standard Pages, News Items or Calendar type assets are the best
You should nest the Asset Listing that displays the comments INSIDE a content div within the asset builder that creates the comments.  This may sound counter intuitive but this will allow the comment listing to be refreshed and reloaded after new comments are created by the builder. It can be particularly useful if you are using the comments on an internal website like a knowledge base where comments can be made instantly live by the user instead of going through an approval process. You can do this by editing the contents of the Logged in bodycopy.

Nest content screenshot 

Nest content part 2 screenshot 

 Create a Paint Layout

  1. Create a new Paint Layout and give it an appropriate name
  2. Acquire the locks and select the same types that you set in step 10 for the Asset Builder
  3. Expand the Paint Layout and then expand the Type Formats folder to access the contents for the different types of assets
  4. Right click on the Default Format if all the assets will display in the same way or pick one of the types and select Edit Contents
  5. Acquire the locks and create a new div above or below the div with depending on where you would like the comments information to display. The asset contents keyword will print the regular page contents for the current asset the user is viewing
    Create new content div screenshot
  6. Select Raw HTML and set the content type to Nest Content
  7. Nest in the Asset Builder that creates the comments
You have now created a comments listing and comments Asset Builder. All that's left to do is apply the Paint Layout to the assets that you would like the comments to be used on.

You can go back and change the No Results body copy for the asset listing to display a message encouraging people to leave the first comment and you can also customise the Asset Builder create form if you so choose.


Comments


  1. Avatar
    07 Jun 2013 1:03pm Gaz
    Nice step-by-step guide. 

    We've been wanting to so something like this for a while on our site but we couldn't think of a way to set up the asset builder to send notifications to the owner of the page that the comments are added to, so that they can go in and approve them. Any ideas?
  2. Avatar
    07 Jun 2013 1:03pm Anton Babushkin
    Hi Gaz,

    You'll need to setup a new Trigger that fires on Asset Created / After Asset Built that sends an Email to a nominated Email box. You can do this via the Trigger manager in the System Management.
    1. Avatar
      03 Aug 2013 8:17pm Bert
      I am totally wowed and preaerpd to take the next step now.
  3. Avatar
    07 Jun 2013 1:03pm tim davison
    Two questions:
    - When I implement the above, after creating the asset the url is appended with a '?'. If I do a browser refresh it resubmits and creates another comment exactly the same as the first. Is there are way to ensure the url stays on the page?
    - Is there any way to specify defaults for asset builder form? All my users will be logged in, so I want the asset name to be the user's name, but I can;t see any defaults.
  4. Avatar
    01 Oct 2014 12:50pm nathan
    Hi tim.. 
    Not sure if this is the best way to do it, but I just added a hidden field to the form along the lines of:

    <input type="hidden" name="comment_0_name" value="whatever you want">

    Probably won't hold up if they change the naming convention in future versions, but wasn't sure how it do it otherwise.
Post a new comment Post a new comment

Build your own search

By Ladoo posted on 20 Oct 2011

You can create your own personal Search Page to assist with locating and editing the content you look after. This can be especially helpful in larger systems where quick search becomes less accurate.

Output content to a file

By Ladoo posted on 17 Nov 2011

As well as HTML and text, Matrix can be configured to directly output XML, iCal, RTF and even Word and Excel documents, so that users can directly download and work with these files.

Pretty as a picture Image Gallery

By Liam Coltman posted on 13 Nov 2010

Image Galleries can help to add a bit of colour to your website. With a little bit of tinkering you can make an image gallery that will rival the Louvre

Trigger happy images

By Liam Coltman posted on 23 Aug 2010

Triggers are a very powerful feature in MySource Matrix. Learn how to set up a trigger to create image varieties

Dynamic Asset Listings

By Liam Coltman posted on 14 Aug 2010

Learn how to make you asset listings dynamic so they can be reused across multiple pages on your site

Paint Layouts

By Liam Coltman posted on 06 Mar 2010

The best way to think of a Paint Layout is a Design File for your page content.

News delivered to your doorstep

By Liam Coltman posted on 10 Sep 2010

With users becoming more and more demanding on their news and website updates RSS provides the perfect option to keep readers up to date with what is happening on your site.

Matrix PHP API - Creating Standard Page Assets

By Anton Babushkin posted on 28 Feb 2011

Using the Matrix PHP API can allow you to do more than you previously would have thought possible. This article will teach you how to create Standard Page assets as well as give you some insight into when you could utilize the PHP API in the real world.

Release notes for Matrix 1.2

By Anton Babushkin posted on 16 Jul 2013

You can create your own personal Search Page to assist with locating and editing the content you look after. This can be especially helpful in larger systems where quick search becomes less accurate.

Search

By Ladoo posted on 23 Feb 2012

Most content management systems only offer basic search functionality, and Matrix is no exception.