List Comments and Replied Comments on a Page

Scenario

When you have a page with a lengthy discussion or you want to keep track of the activity, you might want to get an overview of the discussion at a glance.

This report compiles and display comments, commentators and replied comments of a page inside a table.


Result


Recipe

Ingredients

Add-ons

Platform

Level

INTERMEDIATE

Estimated time

10 minutes

Macros

Suppliers

Storage format

Macro structure

You can recreate the example in the editor view:

Steps

  1. Create a report-table macro to host the report inside a table.

  2. Add a Local Reporter macro inside the report-table macro, because we are interested to report on a single page only. To get all comments on the page, make sure key is set to "page:all comments".

  3. Now, create as many report-column macros with report-info macros as you wish. These would host all the details of each comment. To retrieve details of the comments, we can make use of the keys available through Comment Supplier.

    In this example, we create these columns with corresponding key for report-info macros:
    1. The user who commented, with key "comment:creator"
    2. The comment summary, with key "comment:summary"
    3. The user(s) who replied to the comment, with key "comment:repliers"
    4. The comment summary, with key "comment:children > collect body > collect text ". This retrieves the replies and displays the comment replies.

  4. (Bonus) To calculate the time lapsed since the comment was made, create another report-column macro called "Days ago". Enable injection, because we are going to use an advanced notation. Create a report-eval macro and set format to "#" so the number of days will be rounded. To calculate, use this notation for the report-eval macro: 

    (%global:current date>date:milliseconds% - %comment:creation date>date:milliseconds%)/1000/60/60/24