Kentico CMS 6.0 Developer's Guide

Using the In-line abuse report web part in transformations

Using the In-line abuse report web part in transformations

Previous topic Next topic Mail us feedback on this topic!  

Using the In-line abuse report web part in transformations

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

The Inline abuse report web part appears as a link with the Report abuse text. After clicking the link, a dialog appears, letting the site visitor send abuse report to the site administrators. Apart from using it as a standard web part, you can also use it in transformations to have the Report abuse link displayed with dynamically loaded content.

 

To see how the In-line abuse report web part is used, you can go to the Examples -> Web parts -> Message boards -> Message board page of the sample Corporate Site. As you can see in the screenshot below, the Report abuse link is included with each message on the board.

 

devguide_clip0457

 

This is achieved using the In-line abuse report web part in the transformation used for displaying board messages. If you go to properties (Configure) of the Message board web part and edit the Message transformation (the community.transformations.MessageBoard transformation should be selected by default), you should see the same code as below.

 

<%@ Register Src="~/CMSModules/MessageBoards/Controls/MessageActions.ascx" TagName="MessageActions" TagPrefix="cms" %>

<%@ Register Src="~/CMSModules/AbuseReport/Controls/InlineAbuseReport.ascx" TagName="AbuseReport" TagPrefix="cms" %>

<div class="CommentDetail">

    <asp:Panel ID="pnlRating" runat="server" CssClass="CommentRating" />

    <table width="100%">

        <tr>

            <td class="CommentUserName" style="width100%">

         <%# IfEmpty(Eval("MessageURL"), Eval("MessageUserName", true), "<a href=\"" + Eval("MessageURL", true) + "\" target=\"_blank\">" + Eval("MessageUserName", true) + "</a>")%>              

      </td>

        </tr>

        <tr>

            <td class="CommentText">

         <%# CMS.GlobalHelper.TextHelper.EnsureLineEndings(Convert.ToString(Eval("MessageText", true)), "<br />")%>

      </td>

        </tr>

        <tr>

            <td class="CommentDate">

         <%# GetDateTime(Eval("MessageInserted")) %>

            </td>

        </tr>

        <tr>

            <td align="right" class="CommentAction">

         <cms:MessageActions ID="messageActions" runat="server" />

            </td>

        </tr>

        <tr>

            <td align="right" class="CommentAction">

                 <cms:AbuseReport ID="ucInlineAbuseReport" runat="server" ReportObjectType="board.message" ReportObjectID='<%# Eval("MessageID") %>' ReportTitle='<%# "Message board abuse report: " + Eval("MessageText") %>' CMSPanel-SecurityAccess="AuthenticatedUsers" />

            </td>

        </tr>

    </table>

</div>

<hr style="border1px solid #CCCCCC;"/>

 

Let's take a closer look at the highlighted parts of the code. The highlighted line at the top is here to register the web part (actually control) so that it can be used in transformation code. As you can see, the web part code file is ~/CMSModules/AbuseReport/Controls/InlineAbuseReport.ascx.

 

The second highlighted section is the actual web part, identified by the tag name and prefix defined in the Register tag. The ReportObjectType="board.message" and ReportObjectID='<%# Eval("MessageID") %> parameters ensure that it will be possible to view details of a particular message (source of reported abuse) from the administration interface. These parameters pass the ID of the particular board message along with the report, so that the message can be identified and a link to it created. The ReportTitle='<%# "Message board abuse report: " + Eval("MessageText") %> parameter defines the title of the report displayed in the administration interface. The last parameter - CMSPanel-SecurityAccess="AuthenticatedUsers" - ensures that the link will be displayed only to authenticated users.

 

This way, you can use the web part in transformations of any document types you need. The only limitation is that the object details functionality is available only with board messages, forum posts and blog comments. Abuse reporting is still possible with other object types, but no object details are passed with the report and therefore can't be displayed in the administration interface.