pw_comments is an extension for TYPO3 CMS which adds the possibility to post comments on pages
(similar to the comment function in blogs) or extension entries like news (or even tt_news).
Requirements of pw_comments
PHP: ^8.2
TYPO3 CMS: ^13.4
Features
Adds the possibility for users to post comments on pages
Easy to integrate into existing or new TYPO3 sites
Compatible with other extensions like EXT:news or EXT:tt_news
Very(!!) customizable thanks to TypoScript (constant manager fully supported)
Supports replies/answers to comments
Up/Down Voting for comments and replies
Gravatar support
Spam protection:
Bad word list for comment message, name and mail address
"Hidden field" spam protection
Customizable waiting time between two comments
Moderate new comments
Change order of comments and/or replies (separately adjustable)
Comments are stored at the pid of the page where they have been written. To see the comments just switch to list view
and click on the page.
Activate moderated comments
If a submitted comment is moderated and not yet visible, you have to activate it manually. To do this, switch to list
view and choose the page where the comment has been posted. Comments are displayed like that:
|comment_be_list|
You can click on the bulb to make the comment visible or click on the pencil to see/modify the comment's details.
Getting informed about new comments
pw_comments sends out an e-mail notification for each new comment. The default e-mail template contains a back end
link to the comment details. This requires a valid back end session.
Inform your users
It is also possible to send mails to comment authors themselves when:
- a new comment has been written
- a moderated comment has been published
After loading the extension onto the server, you will have to install it like every other extension. The installation
will create a new table for storing comments.
You can wire the extension's TypoScript into your site in two ways. Pick one — both produce the same result.
Option A: Site Set (recommended, TYPO3 v13+)
Add the site set to your site configuration in config/sites/<identifier>/config.yaml:
The pwcomments/comments set is required; pwcomments/styling ships the
optional default CSS. Settings are then editable in the backend module
Site Management → Settings.
Option B: Static template includes (legacy, still supported)
Edit your root TYPO3 template and include the static templates:
|comment_static-includes|
The Main Static Template must be included. The Styles are optional, but recommended.
Settings are then editable via the Constants Editor under the Template module.
When the includes are in place (via either option) you can access several libs to include pw_comments
into your page (as described in the chapter Configuration).
Important
When you want to work with mail notifications, you should configure an absolute URL (like https://my-domain.com/) in
TYPO3's site configuration instead of a plain /. This is required by TypoLink to create absolute URLs in mails.
Configuration
First installation
After you've successfully installed pw_comments and added the static setup to your TYPO3 template you can simply
add the following TypoScript lines to your main column output in order to output the comments:
This will display the comments on every page. You can use any conditions you want
(for example: [globalVar = TSFE:page|layout = 1]) to define the visibility of comments for specified pages
(since you probably wouldn't want comments to appear on all pages).
Settings
pw_comments includes the following settings which make it highly customizable:
You may use TypoScript in the settings. For example:
plugin.tx_pwcomments.settings.successfulAnchor = TEXT
plugin.tx_pwcomments.settings.successfulAnchor {
data = page:title
wrap = #thanksForYourCommentOnThePage|
}
Copied!
Flexibility with conditions
You can define the settings even further using conditions. The default setup, which is delivered in the static setup,
contains different settings for users who are logged in:
This will disable moderation for new comments, reduce the minimal number of seconds between two comments and replace
the input field for name and e-mail with the string: "You are logged in as: <b>Blah</b>" for logged in users.
How to use pw_comments with other extensions
Since version 1.1 it is possible to use pw_comments not only with pages but also with tt_news entries or any other
extension - thanks to the new entryUid.
You can enable or disable the usage of entryUid by setting TypoScript conditions. If you do so pw_comments will search
for comments which are located on the current page (pid). For example, if you use tt_news the pid for all news is the
same, because the pid only defines the page which contains the detail-view-plugin and not the news entry itself.
If you enable the entryUid you can define its content yourself. In this example you could fill in the news-entry-uid
of current news.
In TypoScript this could look like this:
[request.getQueryParams()['tx_news_pi1'] && request.getQueryParams()['tx_news_pi1']['news'] > 0]# Enable the usage of entryUid and define entryUid
plugin.tx_pwcomments.settings {
useEntryUid = 1
entryUid = TEXT
entryUid.data = GP:tx_news_pi1|news
}
# And add comments if not done yet
lib.content.80 < lib.pwCommentsIndex
lib.content.85 < lib.pwCommentsNew
[global]
Copied!
First you check the condition "Am I currently on a news detail view?". If this is the case, the GET-parameter
tx_ttnews[tt_news] exists and is greater than zero.
Then you tell pw_comments to use the entryUid and fill it with this GET-parameter value, which is basicly the uid
of the news_entry.
Now pw_comments respects the uid of the news itself and you can add several separate comments to all published
news entries.
Of course you can also use this feature with any other extension - just replace the GET-parameter.
It is not possible to use more than one instance of pw_comments per page!
Libraries for further usage
The static setup of pw_comments contains some libs to make your work more comfortable:
lib.pwCommentsIndex
This displays the comments with the Fluid template engine.
lib.pwCommentsNew
This displays the form for posting comments. You can disclaim this form if you want to make the comments read only.
lib.pwCommentsGetCount
Returns the number of comments on the current page. You can use this lib with the f:cObject viewhelper in Fluid as well.
Warning
If you have the option useEntryUid enabled, the amount of comments will just respect the comments per
page, not per eg. news entry. You have to modify the typoscript for this functionality a little bit. Just
Similar to lib.pwCommentsGetCount, but adds the word 'comment/s' behind the number of comments.
i.e: "0 comments", "1 comment", "2 comments"
CSS default style
The static setup provides some basic CSS styles. If you want to disable them simply paste this into your TypoScript:
plugin.tx_pwcomments._CSS_DEFAULT_STYLE >
Copied!
Author or authorName?
The author of a comment is saved in two diffent ways: If an unregistred user writes a comment the fields authorName
and authorMail are filled. If the user is registered the model of the user is linked to the comment in the field author.
authorIdent
Each comment author gets an authorIdent, stored in comments and votes. If user is logged in, it contains the uid of
the frontend user. Otherwise it contains a randomly generated string. For not logged in users, this string will be
stored as cookie with key tx_pwcomments_ahash.
Overwrite translations
If you want to change translations, like the upvote/downvote label, just use typoscript:
You can replace the name input field with something else. This makes sense if it is used together with conditions which check if the user is logged in.
If enabled an avatar image is displayed for each comment. If disabled, no image is displayed at all.
showGravatarImage
Property
showGravatarImage
Data type
boolean
Default
1
Description
Enables or disables the usage of gravatar images. If disabled, a static icon is displayed.
gravatarSize
Property
gravatarSize
Data type
integer
Default
50
Description
Size (in pixel) of gravatar images
gravatarDefault
Property
gravatarDefault
Data type
string
Default
mm
Description
This specifies the default image for e-mail addresses without a gravatar
Mails to comment author
Important
When you want to work with mail notifications, you should configure an absolute URL (like https://my-domain.com/) in
TYPO3's site configuration instead of a plain /. This is required by TypoLink to create absolute URLs in mails.
Defines the path to the Fluid template which should be used for the e-mail to comment author.
sitenameUsedInMails
Property
sitenameUsedInMails
Data type
string
Description
When this option is set, it replaces the getHostname() output, used in mail subject.
Moderation and e-mail notification
Important
When you want to work with mail notifications, you should configure an absolute URL (like https://my-domain.com/) in
TYPO3's site configuration instead of a plain /. This is required by TypoLink to create absolute URLs in mails.
If this option is enabled, comments are not automatically visible. A back end user has to activate them first.
sendMailOnNewCommentsTo
Property
sendMailOnNewCommentsTo
Data type
string
Description
One or more e-mail addresses who will be informed every time a new comment has been submitted. Separate
multiple recipients using a comma or leave empty to disable e-mail notifications.
sendMailTemplate
Property
sendMailTemplate
Data type
string
Default
EXT:pw_comments/[...]/mail.html
Description
Defines the path to the Fluid template which should be used for notification e-mails
sendMailMimeType
Property
sendMailMimeType
Data type
string
Default
text/plain
Description
Defines the MIME-type of the e-mail body. Please note that changes made here also need to be regarded in the
appropriate template.
AI Enhanced Moderation
The pw_comments extension now supports AI-enhanced content moderation using OpenAI's moderation API to automatically detect and flag inappropriate content before it's published.
Note
As of the time of writing, OpenAI's moderation API endpoint is free to use and does not consume your API usage quota or budget. This makes it an excellent choice for automated content moderation without additional costs.
Features
Automatic Content Analysis: Comments are automatically analyzed for potentially harmful content
Real-time Detection: Content is evaluated immediately upon submission
Detailed Categorization: The system provides specific categories of flagged content (hate speech, harassment, violence, etc.)
Confidence Scoring: Each analysis includes confidence scores for different violation categories
Backend Integration: Moderation results are stored and visible in the TYPO3 backend
Flexible Thresholds: Configure custom sensitivity levels for content flagging
enableAiModeration
Property
enableAiModeration
Data type
boolean
Default
0
Description
Enables AI-powered content moderation using OpenAI's moderation API. When enabled, all new comments will be automatically analyzed for potentially harmful content before being published.
aiModerationProvider
Property
aiModerationProvider
Data type
string
Default
openai
Description
Specifies which AI moderation service to use. Currently supports "openai" for OpenAI's moderation API. Additional providers may be added in future versions.
aiModerationThreshold
Property
aiModerationThreshold
Data type
float
Default
0.7
Description
Sets the confidence threshold (0.0 to 1.0) for flagging content as inappropriate. Lower values are more sensitive and will flag more content. A value of 0.7 provides a good balance between catching problematic content and avoiding false positives.
aiModerationApiKey
Property
aiModerationApiKey
Data type
string
Description
Your OpenAI API key for accessing the moderation service. This key is required when AI moderation is enabled. Keep this key secure and never commit it to version control.
Configuration Example
To enable AI moderation in your TypoScript configuration:
Store your OpenAI API key securely using TYPO3's environment variables or configuration files that are not tracked in version control.
Backend Integration
When AI moderation is enabled, the comment records in the TYPO3 backend will show additional fields:
AI Moderation Status: Whether the comment was flagged by the AI system
AI Moderation Reason: Detailed explanation of why the content was flagged
AI Moderation Confidence: The confidence score of the moderation decision
AI Moderation Control: Manual override controls for administrators
Content Categories
OpenAI's moderation API detects the following categories of potentially harmful content:
hate: Content expressing hate or promoting hatred
hate/threatening: Hate speech that includes threats or incites violence
harassment: Content intended to harass, bully, or intimidate
harassment/threatening: Harassment that includes threats
self-harm: Content promoting self-harm or suicide
self-harm/intent: Content with explicit intent to harm oneself
self-harm/instructions: Content providing instructions for self-harm
sexual: Sexual content (may not be appropriate for all audiences)
sexual/minors: Sexual content involving minors
violence: Content depicting or promoting violence
violence/graphic: Graphic violent content
Security Considerations
API keys should be stored securely and rotated regularly
Consider implementing rate limiting to prevent API abuse
Monitor your API usage even though the moderation endpoint is free
Error Handling
The system includes comprehensive error handling:
API Key Missing: Comments are processed normally with a warning logged
API Failures: Detailed error logging with comment context
Rate Limiting: Graceful handling of API rate limits
Network Issues: Fallback to manual moderation when the service is unavailable
Troubleshooting
AI moderation not working:
Verify your OpenAI API key is correctly configured
Check that enableAiModeration is set to 1
Review the TYPO3 system log for any error messages
Ensure your server can make outbound HTTPS requests to OpenAI's API
Too many false positives:
Increase the aiModerationThreshold value (e.g., from 0.7 to 0.8)
Review the specific categories being flagged in the backend
Comments not being flagged:
Decrease the aiModerationThreshold value (e.g., from 0.7 to 0.5)
Verify the API is responding correctly by checking the system logs
Relative date
Property
Type
relativeDate.absoluteFormatFallback_
string
relativeDate.absoluteFormatFallback
Property
relativeDate.absoluteFormatFallback
Data type
string
Default
%d.%m.%Y
Description
The dates of comments will be shown as relative dates (for example "2 hours ago"). After a longer period of
time, the view helper switches to an absolute date. This setting controlls the output of this absolute date.
Enables or disables the reply link and adds a hidden field to new comment form with uid of parent comment. If
this option is activated the next one should be activated, too.
showRepliesToComments
Property
showRepliesToComments
Data type
boolean
Default
0
Description
Enables or disables the display of already existing replies to comments.
countReplies
Property
countReplies
Data type
boolean
Default
1
Description
If true, the placeholder {commentCount} will also count replies on comments. Otherwise just comments
(no replies) will get counted.
Enables or disables the voting controls for comments.
enableReplyVotes
Property
enableReplyVotes
Data type
boolean
Default
1
Description
Enables or disables the voting controls for replies.
enableVoting
Property
enableVoting
Data type
boolean
Default
1
Description
If disabled votes are visible but users may not vote for comments/replies. This is useful if you want to
restrict possibility to vote for eg. logged in users but show the votings.
hideVoteButtons
Property
hideVoteButtons
Data type
boolean
Default
0
Description
If enabled the voting buttons are not visible. Caution: The voting functionality itself is still enabled.
ignoreVotingForOwnComments
Property
ignoreVotingForOwnComments
Data type
boolean
Default
1
Description
If enabled users are not allowed to vote for their own comments/replies.
If this option is enabled, a "accept terms" checkbox is displayed which is required to post new comments.
termsTypolinkParameter
Property
termsTypolinkParameter
Data type
string
Default
t3://page?uid=1
Description
A typolink parameter string, to define link to terms in checkbox label. You can also link to files
or external urls.
Know problems / Troubleshooter
fe_user not found
If you work with registred users, they will need a special property set in order to be recognized by Extbase. The
following extension explains which field that is and sets it to default: Extension 'fe_users_default_extbase_type'
Links in mails does not start with domain
pw_comments is able to send mails to comment author and administrators. Those mails may contain links.
In case your links in mails start with "/", you need to adjust the "Entry Point" (base) in the current site
configuration of TYPO3.
Reference to the headline
Copy and freely share the link
This link target has no permanent anchor assigned.The link below can be used, but is prone to change if the page gets moved.