7

UGC has a ratings feature that lets visitors rate items and CMS users the ability to see these ratings for those items.

I see how this works on a per-item basis--Template Building Blocks add the tag or control, visitors rate and see the ratings on the website, and UGC extends the CMS to show these to CMS users.

Does UGC have a delivery-side API? Is there a way to find and then present the "most popular" or "highest rated" items in delivery?

1 Answer 1

5

Q1. Does UGC have a delivery-side API?

UGC does not appear to have a documented API (I couldn't find one on SDLTridionWorld or within SDLLiveContent), other than a predefined set of server control tags. These can be found in the online documentation here.

For example:

<ugc:Comments runat="server" OrderDescending="true">
 <ugc:ForEachComment runat="server">
  <div class="comment"><ugc:ContextVariable var="ugcComment.content" runat="server"/></div>
 </ugc:ForEachComment>
</ugc:Comments>

Looking through some other Tridion Stack Exchange answers, it appears that you may be able to use the (undocumented) classes in the Tridion.ContentDelivery.UGC namespace to retrieve the UGC items.

Also, as can be seen in the UGC system diagram (login required), the comments are retrieved from the UGC data store via the Community Web Service (OData). If you monitor the requests to this service then you may be able to determine the structure of the OData requests being sent and use these within your own code. This would obviously be unsupported too.

Q2. Sorting the comments

According to Changing the appearance of comments on the published Web page in the online documentation, an editor can determine whether to sort the results by:

  • Chronological (or reverse chronological) order, or
  • By the username of the person making the comment (alphabetically or reverse alphabetically)

However, the UGC Commands -> Comments section of the online documentation (login required) is sketchy about how this is implemented within the server control tag, and only lists a single orderDescending (JSP or TCDL) or OrderDescending (ASP.NET) attribute against the Comments tag:

<ugc:Comments runat="server" OrderDescending="true">

You should be able to determine the attributes used for determining whether to sort on the username or chronologically by looking at the output of the published page (containing a configured comments section).

There does not appear to be a way to sort by "most popular" or "highest rated" (unless it is not documented)

6
  • I'm sure a call to ItemStats via the UGC service will give you average ratings and comment count I seem to remember.
    – Neil
    Commented Dec 12, 2014 at 13:38
  • Thanks Neil. Is the UGC Web Service documented anywhere? Commented Dec 12, 2014 at 13:40
  • 1
    Not that I've seen - we just took a look inside the Tridion DLLs and worked it out from there.
    – Neil
    Commented Dec 12, 2014 at 13:41
  • Great. That is what I suspected. Cheers. Commented Dec 12, 2014 at 14:16
  • 1
    This is good, thanks Jonathan and Neil. Undocumented, but in the DLLs/jars beats database queries. :-) Since the libraries only change on upgrades, I would implement this and document it out for the next upgrade. A set of "fallback" items or at least a setup that doesn't show errors to visitors on any issues would be good too. Commented Dec 12, 2014 at 20:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.