Magnolia 5.3 reached end of life on June 30, 2017. This branch is no longer supported, see End-of-life policy.
The Commenting module adds a commenting feature on any Magnolia page. The module is built on the Forum module and comments are managed in the Forum app. The module is available in the STK.
The benefits of built-in commenting, as opposed to an external service include:
The STK also supports IntenseDebate, a third party commenting service.
The module is configured in /modules/commenting
.
Node name | Value |
---|---|
modules | |
commenting | |
config | |
dialogs | |
templates |
The module includes two components:
stkArticle
and its extensions, but you can make it available on any template. See Adding components to templates for more.Here's the Comments component on the /demo-project/about/history
page and Latest Comments component in extras
area on a related page.
The comments
component provides the commenting functionality. When you add it to a page commenting is automatically enabled.
The component definition is at Configuration > /modules/commenting/templates/components
/comments
:
Node name | Value |
---|---|
commenting | |
templates | |
components | |
comments | |
parameters | |
avatarImage | /docroot/commenting/avatar.jpg |
forumName | pagecomments |
description | paragraph.comments.description |
dialog | commenting:comments |
i18nBasename | info.magnolia.module.commenting.messages |
modelClass | info.magnolia.module.commenting.frontend.action.PageComments |
renderType | stk |
templateScript | /info/magnolia/module/commenting/frontend/comments.ftl |
title | paragraph.comments.title |
parameters
:dialog
: comments
dialog has a single field, Alternative Text. The content renders if the user does not have permission to view or post comments. By default anonymous commenting is allowed. See Security for more.modelClass
:
PageComments
: templateScript
: comments.ftl
(GIT):ContentMapList
, including the gravatar, title, message, username, date and inline reply link for each.comment-form.inc.ftl
(GIT) script that renders the form.The Latest Comments component is a teaser that can be used in extras
area to display comments made on a related page.
The latestComments
component definition is at Configuration > /modules/commenting/templates/components
/latestComments
:
Node name | Value |
---|---|
commenting | |
templates | |
components | |
latestComments | |
parameters | |
forumName | pagecomments |
description | paragraph.latestComments.description |
dialog | commenting:latestComments |
i18nBasename | info.magnolia.module.commenting.messages |
modelClass | info.magnolia.module.commenting.frontend.action.LatestComments |
renderType | stk |
templateScript | /info/magnolia/module/commenting/frontend/latestComments.ftl |
title | paragraph.latestComments.title |
parameters
:forumName
: Comments are stored in the pagecomments
forum created by the module. See Forum app for more.dialog
: latestComments
allows editor's to include a title, select the page that comments are sourced from, set the maximum number of comments, and set the description (message) length.modelClass
:
LatestComments
retrieves a list of the latest page comments for a specified page. templateScript
: latestComments.ftl
(GIT) renders the component title, list of comments from the specified page, and respects any limitations set in the dialog.Here's the latestComments
dialog.
Page comments are stored in and rendered from the forum
workspace. Only properties defined in the component dialogs are stored in the website
workspace. Here's the comments
component in comments
area of the /demo-project/about/history
page in the website
JCR browser, accessible in Tools > JCR.
Node name | Value |
---|---|
history | |
comments | |
0 | |
alternativeText | <p>Please <a href="${link:{uuid:{7b17a30a-e8bb-4... |
You can add the commenting components to any template. The comments
component adds the commenting feature automatically. Ideally the comments
component should reside in it's own area, but there is no technical reason that it cannot be add to content
area, for example. See Rendering comments area for an alternative STK method.
The example configuration below adds the comments
component to content
area and the latestComments
component to extras1
area of the stkSection
template configured at STK > Template Definitions /pages/stkSection
.
Node name | Value |
---|---|
pages | |
stkSection | |
areas | |
main | |
areas | |
intro | |
opener | |
content | |
availableComponents | |
stkTeaser | |
... | |
comments | |
id | commenting:components/comments |
templateScript | /templating-kit/pages/section/contentArea.ftl |
title | templates.stkSection.areas.main.content.title |
class | info.magnolia.module.templatingkit.templates.SectionMainArea |
templateScript | /templating-kit/pages/section/mainArea.ftl |
extras | |
areas | |
extras1 | |
availableComponents | |
latestComments | |
id | commenting:components/latestComments |
sectionHeader |
In the examples below dummy comments were added on the /demo-project/about/subsection-articles
page and referenced on the /news-and-events
page. Both pages are based on the stkSection
template.
In the STK the comments
component is made available in main/comments
area in the template prototype. This is configured in STK > Site Definitions /default/templates/prototype/areas/main/areas/comments/availableComponents
.
Node name | Value |
---|---|
default | |
templates | |
prototype | |
areas | |
main | |
areas | |
intro | |
comments | |
availableComponents | |
stkComments | |
id | commenting:components/comments |
The configuration above makes the comments
component available on all templates, but it is in fact only available on the stkArticle
template (and by extension on all content templates). This is because main
area in the prototype is rendered by /templating-kit/pages/global/mainArea.ftl
and in stkArticle
by /templating-kit/pages/content/mainArea.ftl
. You can find these configurations at STK > Site Definitions /default/templates/prototype/areas/main/templateScript
and STK > Template Defintions /pages/stkArticle/areas/main/templateScript
. See main and comments area for more.
Prototype
<div id="main" role="main"> [@cms.area name="breadcrumb" content=content/] [@cms.area name="intro" content=content/] [@cms.area name="content"/] </div><!-- end main -->
Article
<div id="main" role="main"> [@cms.area name="contentNavigation" content=content/] [@cms.area name="breadcrumb" content=content/] <div class="text" role="article"> [@cms.area name="intro" content=content/] [@cms.area name="content"/] </div><!-- end text --> [@cms.area name="comments"/] </div><!-- end main -->
You can use the cms:area directive to render the comments
area on any template. Add [@cms.area name="comments"/]
to the relevant main area template.
To demonstrate, we added the directive to /templating-kit/pages/global/mainArea.ftl
that renders main area in the prototype. You can test this in STK > Templates:
/templating-kit/pages/global/mainArea.ftl
.[@cms.area name="comments"/]
to the template.templates
workspace).Here's the comments
area on the stkImageGallery
template.
This is a better alternative than Adding components to templates if you use the STK.
To use IntenseDebate commenting you need to sign up for an account and get an intenseDebateID
:
var idcomments_acct = 'bb0230d1df6448c6043af8d3d1d4daac';
The IntenseDebate connector is configured in the stkComments
component definition in STK > Template Definitions components/features/stkComments
.
parameters/intenseDebateId
: Insert your intenseDebateId
.dialog
: stkComments
dialog configured at STK > Dialog Definitions /components/features/stkComments
has a single hidden field. The editor sees a blank dialog that renders the stkComments
component when saved.templateScript
: comments.ftl
(see below) adapts the script provided by IntenseDebate to render the component in Magnolia.Node name | Value |
---|---|
components | |
features | |
stkComments | |
parameters | |
intenseDebateId | b3828276089a657d0394e1ff40b5f505 |
description | paragraphs.content.stkComments.description |
dialog | standard-templating-kit:components/features/stkComments |
i18nBasename | info.magnolia.module.templatingkit.messages |
renderType | stk |
templateScript | /templating-kit/components/features/comments.ftl |
title | paragraphs.content.stkComments.title |
To enable site-wide IntenseDebate commenting you need to substitute the STK Comments for the Magnolia Comments component in the prototype template at STK > Site Definitions /default/templates/prototype/areas/main/areas/comments
:
availableComponents/stkComments
: Change the value of the id
property to standard-templating-kit:components/features/stkComments
.class
:
CommentsArea
supports the intenseDebateId
configuration property that is made available to the third party software. info.magnolia.module.templatingkit.templates.CommentsAreaNode name | Value |
---|---|
default | |
templates | |
prototype | |
areas | |
main | |
areas | |
intro | |
comments | |
availableComponents | |
stkComments | |
id | standard-templating-kit:components/features/stkComments |
class | info.magnolia.module.templatingkit.templates.CommentsArea |
description | areas.templates.main.comments.description |
title | areas.templates.main.comments.title |
type | single |
Here's the IntenseDebate commenting component on a page.
Magnolia comments are administered and moderated in the Forum app. Comments should be managed and moderated on the public instance because this is where the content is generated. See Forum module for more information about using the Forum app.
Here are 's the comments we added in the previous examples on three /demo-project
pages:
pagecomments
forum that is created when the module is installed. The /modules/commenting/templates/components/comments/parameters/forumName
node of the comments
component points to this forum.eric
(Example Editor (Demo Project)) has full permissions to the app, whereas peter
(Example Editor (Demo Project)) cannot execute certain actions. See App permissions for more.The Moderation subapp allows moderators to manage comments.
The Forum module has a number of configuration properties that control, for example, whether messages are rendered immediately or only after validation. See Configuration for more information.
On installation the Commenting module creates the forum-pagecomments-user
role and assigns it to the anonymous
user on the author and public instances. This gives public users permission to read and write in the forum workspace beyond the path /pagecomments
. This means the user can create and read thread- and comment-nodes.
Role | Permission | Scope | Path |
---|---|---|---|
forum-pagecomments-user | Read/Write | Selected and sub nodes | /pagecomments |
To disable anonymous
commenting, on the public instance remove the forum-pagecomments-user
role from the anonymous
systems user in Security > Systems Users. The comments will disappear from the page.
To grant a user permission to view, but not post, comments create a new role in Security > Roles and assign it to the anonymous user in Security > Systems Users.
Role | Permission | Scope | Path |
---|---|---|---|
forum-pagecomments-view | Read only | Selected and sub nodes | /pagecomments |
You can use the Public User Registration module to require users to register before commenting. The module will automatically assign the forum-pagecomments-user
role to new users, if the role is added at Configuration > /modules/public-user-registration/config/configurations/default/defaultRoles
.
Node name | Value |
---|---|
modules | |
public-user-registration | |
config | |
configurations | |
default | |
defaultRoles | |
anonymous | anonymous |
pur | public-user-registration-base |
comments | forum-pagecomments-user |
Commenting administration and moderation permissions are granted in the Forum module. See Security for more information.
The Commenting module supports multisite (EE) and multilanguage commenting. These options are enabled by default at Configuration > /modules/commenting/config
:
forumPerLocale
: Creates forums for each language defined in the locales
node of the site defintion (EE) or server configuration (CE).multisite
: Creates forums for each site defined in STK > Site definition (EE).Node name | Value |
---|---|
modules | |
commenting | |
config | |
forumPerLocale | true |
multiSite | true |
nestedCommentsByDefault | false |
The comments
component uses the pagecomments
forum by default. This is set in the forumName
property in Configuration > /modules/commenting/templates/components/comments/parameters/forumName
. To enable multisite and mulitlanguage commenting, delete the value "pagecomments"
and leave it blank. The system will then create new forums automatically in the following formats:
forumPerLocale
enabled: pagecomments_<language identifier>
. The forum for the defaultLocale
, for example pagecomments_en
, is created when you add the comments
component to any page. The forums for additional locales, for example, pagecomments_de
, are created when the first comment in the language is posted. multiSite
enabled: pagecomments-<site name>
. A forum is created for each site, for example pagecomments-demo-project
and pagecomments-demo-features
, when the comments
component is added to any page of the site.forumPerLocale
and multiSite
enabled: pagecomments-<site name>_<language identifier>
. The forum for the defaultLocale
, for example pagecomments-demo-project_en
, is created when the comments
component is added to any page of the site, and the forums for additional locales, for example pagecomments-demo-project_de
, are created when the first comment in the language is posted.Here are the forums with sample comments with both properties enabled.
To allow editors, moderators or anonymous users to post comments and access the forums create new roles in Security > Roles with the following names and permissions for each expected forum and assign them to the relevant user. * When you save the role the ACL to the Userroles workspace is created automatically.
Access control lists
Role name | Workspace | Permission | Scope | Path |
---|---|---|---|---|
forum-<expected-forum-name>-user | Forum | Read/Write | Selected and sub nodes | / <expected-forum-name> |
Userroles | Read only | Selected | /<role name>* |
Here are two sample comments posted anonymously on the public instance with the forumPerLocale
and multiSite
properties set to true
and relevant roles assigned to the anonymous
system user.
Pages with comments are flushed from the server cache when new comments are posted. The Commenting module registers the
ReferencedPageFlushPolicy
class that takes care of this. The configuration is at Configuration > /modules/cache/config/configurations/default/flushPolicy/policies/FlushByComments
. See Cache module for more information.
Node name | Value |
---|---|
modules | |
cache | |
config | |
configurations | |
default | |
cachePolicy | |
browserCachePolicy | |
executors | |
flushPolicy | |
policies | |
flushAll | |
FlushByComments | |
repositories | |
o | forum |
class | info.magnolia.module.commenting.cache.ReferencedPageFlushPolicy |
class | info.magnolia.module.cache.DelegateFlushPolicy |
You can also disable the cache for individual pages that use comments at Configuration > /modules/cache/config/configurations/default/cachePolicy/voters/urls/excludes
. Duplicate the dotMagnolia
node and set the pattern
to the page URL. The example configuration below disables the cache for the /demo-project/about/history
page.
Node name | Value |
---|---|
config | |
configurations | |
default | |
cachePolicy | |
voters | |
urls | |
includes | |
excludes | |
dotMagnolia | |
comments-history | |
class | info.magnolia.voting.voters.URIStartsWithVoter |
pattern | /demo-project/about/history |
not | true |
level | 1 |
deny |
This section requires the Observation module that is not installed by default, even though other modules bootstrap configurations to the Configuration > /modules/observation/config/listenerConfigurations
node. If you do not see a /observation/version
node the module is not installed. Before installing the module export the versionTemplatesOnChange
, versionResourcesOnChange
, sendMailOnPageComments
and generateCategories
listener configurations for later use. These are useful and will be overridden on installation of the module.
For mail notifications to be sent valid SMTP settings need to be configured. You can set these in the Mail tools app accessible at Tools > Mail tools. See Mail for more information about using the app.
PageCommentsNotification.ftl
script throws an exception when retrieving page link. See MGNLCMNT-103.
The pageCommentsNotification
template is configured at Configuration > /modules/mail/config/templatesConfiguration/pageCommentsNotification
. See Templates configuration for more information. The Observation module uses this mail template to send email notifications.
Node name | Value |
---|---|
modules | |
config | |
templatesConfiguration | |
pageCommentsNotification | |
contentType | html |
subject | This is a test email for freemarker template |
templateFile | /info/magnolia/module/commenting/PageCommentsNotification.ftl |
type | freemarker |
You can test this template in Verify Settings in the Mail tools app.
The sendMailOnPageComments
event listener observes the forum
workspace and sends a preconfigured email when a new comment is posted. This is one of the listener configurations that is overridden when you install the Observation module. See Observation module for more information about configuring listeners.
To use the listener:
sendMailOnPageComments
event listener into the Configuration > /modules/observation/config/listenerConfigurations
node.active
property to true
.from
and mailTo
properties. Node name | Value |
---|---|
modules | |
observation | |
config | |
listenerConfigurations | |
sendMailOnPageComments | |
listener | |
command | |
class | info.magnolia.module.mail.commands.MailCommand |
params | |
model | |
class | info.magnolia.module.commenting.PageCommentNotifModel |
from | robot@your-company.com |
mailTemplate | pageCommentsNotification |
mailTo | group-pagecomments-managers@your-company.com |
subject | New Page Comment |
type | freemarker |
class | info.magnolia.module.observation.commands.RestrictToNodeTypeEventListener |
nodeType | mgnl:message |
active | true |
delay | 31 |
description | A mail will be sent when a page comment is added |
eventTypes | NODE_ADDED |
includeSubNodes | true |
maxDelay | 40 |
path | /pagecomments/ |
repository | forum |
From a system architecture point of view, dealing with high volumes of comments can be challenging. User-generated content POST requests differ from other content requests in that they cannot be served from cache and have the potential to cause bottlenecks during peak load times.
Magnolia can be configured to run in a clustered environment that provides high availability and load balancing. Content sharing between multiple instances is ensured by Jackrabbit’s clustering feature. For more information about running Magnolia in a Jackrabbit clustered environment, see: