Flagging Inappropriate Asset Content

In a perfect world, people would post nice, kind, and decent content. They would reply to comments with constructive feedback and never lash out at one another. Unfortunately, sometimes people have a bad day and decide to take their frustration out on Joe Bloggs in the form of an inappropriate post. No worries though, Liferay DXP’s asset framework supports a system for flagging content in apps. Letting users flag inappropriate content takes much of the work off site administrators.

Figure 1: Flags for letting users mark objectionable content are enabled in the Message Boards portlet.

Figure 1: Flags for letting users mark objectionable content are enabled in the Message Boards portlet.

This tutorial shows you how to enable flagging of content in a portlet.

Follow these steps:

  1. Make sure your entity is asset enabled.

  2. Choose a read-only view of the entity for the flags. You can display them in one of your portlet’s views, or if you’ve implemented asset rendering, you can display them in the full content view in the Asset Publisher portlet.

  3. In the JSP, include the liferay-flags taglib declaration:

    <%@ taglib prefix="liferay-flags" uri="http://liferay.com/tld/flags" %>
    
  4. Use the -LocalServiceUtil class to get the entity:

    <%
    long entryId = ParamUtil.getLong(renderRequest, "entryId");
    entry = EntryLocalServiceUtil.getEntry(entryId);
    %>
    
  5. Use the liferay-flags:flags tag to add the flags component:

    <liferay-flags:flags
    	className="<%= Entry.class.getName() %>"
    	classPK="<%= entry.getEntryId() %>"
    	contentTitle="<%= title %>"
    	message="flag-this-content"
    	reportedUserId="<%= reportedUserId %>"
    />
    

    The reportedUserId attribute specifies the user who flagged the asset.

Great! Now you know how to let users flag content in your asset-enabled portlets.

Adding Comments to Your App

Applying Social Bookmarks

« Implementing Ratings Type Selection and Value TransformationIntroduction to Item Selector »
この記事は役に立ちましたか?
0人中0人がこの記事が役に立ったと言っています