[Gametize Tech] Feature Knowledge: Support for Player Mentions on CMS
FeaturedJSP/HTML Code Structure
The general code structure excluding styling div
and span
s should minimally comprise of the following.
Rendering the form for a new comment post:
<form action="#">
<%-- Display textarea --%>
<textarea id="[ID Mandatory]" class="validateRequired" rows="2"></textarea>
<%-- Hidden textarea for attribution/mentions processing --%>
<textarea name="message" class="hidden commentTextInput"></textarea>
<textarea class="hidden mentionsIdVal"></textarea>
<textarea class="hidden mentionsNameVal"></textarea>
</form>
Rendering the form for editing an existing comment/reply:
Meaning, existing mentions and attribution formatting needs to be considered.
<form action="#">
<%-- Display textarea --%>
<textarea id="[ID Mandatory]" class="validateRequired" rows="2"><%@include file="/pages/core/business/common/ajax/comment_body_single_plain.jsp" %></textarea>
<%-- Hidden textarea for attribution/mentions processing --%>
<textarea name="message" class="hidden commentTextInput"><%@include file="/pages/core/business/common/ajax/comment_body_single_tags.jsp" %></textarea>
<textarea class="hidden mentionsIdVal"><%@include file="/pages/core/business/common/ajax/comment_body_single_attribution_ids.jsp" %></textarea>
<textarea class="hidden mentionsNameVal"><%@include file="/pages/core/business/common/ajax/comment_body_single_attribution_names.jsp" %></textarea>
</form>
Take note of the textareas and their various purposes:
-
Main Textarea
Include:comment_body_single_plain.jsp
for existing comments.
Renders the comment body as-is, with names displayed, without any formatting.
Example: @Jon Doe @Maki Hello there! -
commentTextInput
which is sent to the backend viamessage
Include:comment_body_single_tags.jsp
for existing comments.
Stores the comment body but with names replaced with[uid:__]
tags.
Example: [uid:8] [uid:2] Hello there! -
mentionsIdVal
Include:
comment_body_single_attribution_ids.jsp
for existing comments.
Stores the existing attribution IDs with|||
as a delimiter.
Example: 8|||2||| -
mentionsNameVal
Include:
comment_body_single_attribution_names.jsp
for existing comments.
Stores the existing attribution names with|||
as a delimiter.
Example: @Jon Doe|||@Maki|||
Javascript Logic
-
A player search is invoked when the
@
character is entered.
Ajax call to action:ajaxsearchplayersformention
-
Upon clicking on a player name from the search results:
-
The name is appended to the main input textarea
(e.g.@Jon Doe
) -
The userId is appended to
mentionsIdVal
with the delimiter.
(e.g.8|||
) -
The user name is appended to
mentionsNameVal
with the delimiter.
(e.g.@Jon Doe|||
)
-
-
Whereas, the hidden field for processing the final comment with all attribution tags accounted for is only handled upon form submit.
-
Replace
@Jon Doe
with[uid:8]
-
Note:
The article's technical specifications and details are subject to potential changes based on our discretion. It is important to note that the information presented in the article might have become outdated or lost its relevance in the present context.
If you are interested to learn more about this, please drop an email to support@gametize.com with your queries regarding the article!
Please sign in to leave a comment.
Comments
0 comments