PwComments

Classification

pw_comments

Version

6.0

Language

en

Keywords

comments

Copyright

2011-2023

Author

Armin Vieweg, Malek Olabi

License

This document is published under the Open Content License available from http://www.opencontent.org/opl.shtml

Rendered

Thu, 26 Jun 2025 20:37:28 +0000

The content of this document is related to TYPO3, a GNU/GPL CMS/Framework available from www.typo3.org.

Table of Contents

Introduction

What is 'pw_comments'? | Requirements of pw_comments | Features | Screenshots | Issues, bugs and feature requests |

What is 'pw_comments'?

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.1
  • TYPO3 CMS: ^12.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)
  • Rich mail notifications

Screenshots

Frontend: Comment output

|comment_fe|

Frontend: Comment voting

|comment_fe_voting|

Backend: Comment Record

|comment_be_record|

Issues, bugs and feature requests

If you have found a bug or you want to submit a request for a new feature, please use the Forge issue tracker at https://github.com/teamneusta/pw_comments/issues

User guide

Where comments are stored

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

Administration

How to get pw_comments

There are two ways to get pw_comments. You can visit the TER at https://extensions.typo3.org/extension/pw_comments and download pw_comments there or you can use Composer to check out the latest version (https://packagist.org/packages/teamneusta/pw_comments).

Installation

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. After the installation you should add the static include to your current TYPO3 template:

|comment_static-includes|

The Main Static Template must be included. The Styles are optional, but recommended.

When the statics have been added you can access several libs to include pw_comments into your page (as described in the chapter Configuration).

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:

page = PAGE
page {
   10 < styles.content.get

   # List comments
   20 < lib.pwCommentsIndex

   # Write new comment
   30 < lib.pwCommentsNew
}
Copied!

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:

plugin.tx_pwcomments.settings.

TypoScript in settings

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:

[loginUser('*')]
   plugin.tx_pwcomments {
      settings {
         moderateNewComments = 0
         secondsBetweenTwoComments = 60

         replaceUsernameWith = COA_INT
         replaceUsernameWith {
            10 = TEXT
            10.data = LLL:EXT:pw_comments/Resources/Private/Language/locallang.xlf:tx_pwcomments.newComment.loggedInAs

            20 = TEXT
            20.data = TSFE:fe_user|user|username
            20.noTrimWrap = | <b>|</b>|

            stdWrap.wrap = <div class="loggedInAs">|</div>
         }

         replaceMailWith = TEXT
         replaceMailWith.stdWrap.char = 0
      }
   }
[global]
Copied!

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.

lib.pwCommentsGetCountWithLabel

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:

plugin.tx_pwcomments._LOCAL_LANG.default.tx_pwcomments.votes.upvote = :)
plugin.tx_pwcomments._LOCAL_LANG.default.tx_pwcomments.votes.downvote = :(

plugin.tx_pwcomments._LOCAL_LANG.de.tx_pwcomments.votes.upvote = :)
plugin.tx_pwcomments._LOCAL_LANG.de.tx_pwcomments.votes.downvote = :(
Copied!

You can also empty labels, if you want to use a background image (via CSS) instead.

Anchors

commentAnchorPrefix

Property
commentAnchorPrefix
Data type
string
Default
comment
Description
Every comment gets an own anchor which contains the uid of the comment. In the default case the anchor will look something like that: #comment1337.

showCommentAnchor

Property
showCommentAnchor
Data type
string
Default
comments
Description
This anchor will appear in front of the comment numbering.

writeCommentAnchor

Property
writeCommentAnchor
Data type
string
Default
writeComment
Description
This anchor will appear in front of the comment form.

successfulAnchor

Property
successfulAnchor
Data type
string
Default
thanksForYourComment
Description
This is the anchor of the flashMessage which notifies the user that his comment has been submitted successfully.

customMessagesAnchor

Property
customMessagesAnchor
Data type
string
Default
customMessages
Description
This anchor is part of index action and marks the flashMessage container to show customMessages, like "You can't vote for your own comment."

EntryUid (for usage with other extensions like EXT:news)

Property Type
useEntryUid boolean
entryUid cObject

useEntryUid

Property
useEntryUid
Data type
boolean
Default
1
Description
Enables or disables the usage of entryUid

entryUid

Property
entryUid
Data type
cObject
Description
Use cObject to define the value of entryUid dynamically. See chapter "How to use pw_comments with other extensions" for further information.

Field replacements

Property Type
replaceUsernameWith cObject
replaceMailWith cObject

replaceUsernameWith

Property
replaceUsernameWith
Data type
cObject
Description
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.

replaceMailWith

Property
replaceMailWith
Data type
cObject
Description
See "replaceUsernameWith"

Gravatar

Property Type
showAvatar boolean
showGravatarImage boolean
gravatarSize integer
gravatarDefault string

showAvatar

Property
showAvatar
Data type
boolean
Default
1
Description
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

senderAddress

Property
senderAddress
Data type
string
Description
Sender's mail address when pw_comments sends out mails.

senderName

Property
senderName
Data type
string
Description
Name to display in mail clients, instead of mail address. (optional)

sendMailToAuthorAfterSubmit

Property
sendMailToAuthorAfterSubmit
Data type
boolean
Default
0
Description
If this option is enabled, the author receives a mail after each comment he/she has written.

sendMailToAuthorAfterSubmitTemplate

Property
sendMailToAuthorAfterSubmitTemplate
Data type
string
Default
EXT:pw_comments/[...]/mailToAuthorAfterSubmit.html
Description
Defines the path to the Fluid template which should be used for the e-mail to comment author.

sendMailToAuthorAfterPublish

Property
sendMailToAuthorAfterPublish
Data type
boolean
Default
0
Description
If this option is enabled, the author receives a mail after a comment he/she has written has been published.

This option requires activated "moderateNewComments".

sendMailToAuthorAfterPublishTemplate

Property
sendMailToAuthorAfterPublishTemplate
Data type
string
Default
EXT:pw_comments/[...]/mailToAuthorAfterPublish.html
Description
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

moderateNewComments

Property
moderateNewComments
Data type
boolean
Default
1
Description
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.

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:

plugin.tx_pwcomments.settings.moderateNewComments = 1
plugin.tx_pwcomments.settings.enableAiModeration = 1
plugin.tx_pwcomments.settings.aiModerationProvider = openai
plugin.tx_pwcomments.settings.aiModerationThreshold = 0.7
plugin.tx_pwcomments.settings.aiModerationApiKey = your-openai-api-key-here
Copied!

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:

  1. Verify your OpenAI API key is correctly configured
  2. Check that enableAiModeration is set to 1
  3. Review the TYPO3 system log for any error messages
  4. 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.

Replying to comments

Property Type
enableRepliesToComments boolean
showRepliesToComments boolean
countReplies boolean

enableRepliesToComments

Property
enableRepliesToComments
Data type
boolean
Default
0
Description
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.

Rights

Property Type
secondsBetweenTwoComments integer
linkUrlsInComments boolean

secondsBetweenTwoComments

Property
secondsBetweenTwoComments
Data type
integer
Default
300
Description
Defines the number of seconds an user has to wait before they may post another comment (includes all pages)

linkUrlsInComments

Property
linkUrlsInComments
Data type
boolean
Default
1
Description
If activated this option recognises and links domains like www.professorweb.de.

Sortings

Property Type
invertCommentSorting boolean
invertReplySorting boolean

invertCommentSorting

Property
invertCommentSorting
Data type
boolean
Default
0
Description
Per default oldest comments are displayed first. If this option is true, the order of comments get inverted (newest comments first).

invertReplySorting

Property
invertReplySorting
Data type
boolean
Default
0
Description
See invertCommentSorting. Affects replies of comments instead of comments itself.

Spam protection

useBadWordsList

Property
useBadWordsList
Data type
boolean
Default
1
Description
Enables or disables the usage of bad word list. This option just checks the entered comment message.

useBadWordsListOnUsername

Property
useBadWordsListOnUsername
Data type
boolean
Default
1
Description
If enabled performs bad words check on entered username. This option may be activated seperately from useBadWordsList option.

useBadWordsListOnMailAddress

Property
useBadWordsListOnMailAddress
Data type
boolean
Default
0
Description
Same like option useBadWordsListOnUsername, just for the entered email address.

badWordsList

Property
badWordsList
Data type
string
Default
EXT:pw_comments/[...]/badwords.txt
Description
Defines the path a bad word list containing regular expressions (one in each line).

hiddenFieldSpamProtection

Property
hiddenFieldSpamProtection
Data type
boolean
Default
hiddenFieldSpamProtection
Description
If enabled an additional hidden field will be added to the comment form. If this field is filled (for example by a bot) the comment will not be saved.

hiddenFieldName

Property
hiddenFieldName
Data type
string
Default
authorWebsite
Description
Field name of the hidden field (type="input")

hiddenFieldClass

Property
hiddenFieldClass
Data type
string
Default
hide_initally
Description
CSS class for hiding the field

Voting

Property Type
enableCommentVotes boolean
enableReplyVotes boolean
enableVoting boolean
hideVoteButtons boolean
ignoreVotingForOwnComments boolean

enableCommentVotes

Property
enableCommentVotes
Data type
boolean
Default
1
Description
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.

Terms accepted

Property Type
requireAcceptedTerms boolean
termsTypolinkParameter string

requireAcceptedTerms

Property
requireAcceptedTerms
Data type
boolean
Default
1
Description
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'