I installed the Clean Blog skeleton with the admin panel, and want to implement comments on my blog posts. The item template already supports JSComments, but I would rather not use a third-party comment provider or try to get my own Discourse up and running. Really I just want a blog with its own commenting system built in that will allow me to approve, deny or delete comments on my posts.
I found two additional Grav plugins for allowing comments: Comments and the more recently updated Better Comments plugin. I tried both, adjusting my item template to include conditionals for each plugin. I did get the Comments plugin working. It puts a really nice basic comment form right at the bottom of a post’s page, where I would expect it to be, and filling out the form sends me an email and also thanks me for my submission, displaying the comment on the page immediately. Unfortunately, although the plugin does allow me to see posted comments in my admin panel, approval is automatic, and the only way to delete a comment is to edit the yaml file for each page that has a comment I want to remove. There is no way with this plugin to even ignore a posted comment in a moderation queue and just let it disappear on its own, and no way to delete any comment from within the comments page in my admin panel.
So I tried Better Comments, which is supposed to allow me to approve and delete comments from my admin panel. The problem is that although an equally clean-looking basic comment form is displayed on each of my posts and I receive an email when I leave a sample comment, I am not thanked for my submission, the comment never shows up in the comments page in my admin panel, it never shows up on the page, and in fact, only the data/comments folder is created on the server; no route folder or page yaml file is ever created.
For both plugins, I copied the included .yaml configuration file into my installation’s user/config/plugins folder and changed the enabled route to /home, since that’s where the Clean Blog skeleton places its sample blog posts where I am leaving test comments. I also cleared my cache, since without doing so, I wasn’t receiving email from Better Comments, but although this solved the email issue, my test comments are still not being written to the files where they should be. Trying to see what exactly is going wrong, I checked both my Grav log and the error log for the web server itself, and no error is being logged anywhere, and no error message of any kind is shown on my page where I leave a test comment. It seems that the plugin is just silently failing after sending the notification email. Has anyone experienced this? If so, how did you resolve it? What could I have done wrong that only affects Better Comments rather than both comment plugins? Did I get stung by a bug? I really do hope not, since I really don’t want to have to sign up with GitHub in order to report it. Thanks for any help.
A very well outlined problem I love it too when I discover a new plugin or feature in a forum post!
Better Comments looks like it is actively maintained. This does sound like an issue as it seems you’ve set it up carefully and done a few basic diagnostics. I have added it to the plugin’s repository linking to this thread.
Thank you. I’ll try to keep up with this issue. I found a solution for
now, but I’d love to try this again soon.
Hi, I´m Better Coments developer.
1.- Remove all plugin files from your Grav CMS
2(a).- Install it with bin/gmp (from your Grav CMS folder in console type bin/gpm install bettercomments).
2(b).- Dowload from this link https://getgrav.org/download/plugins/bettercomments/1.0.10 change the extracted folder name to bettercomments and place it on user/plugins, not in other folder.
I tried all the above. Installed from gpm first and tried it, then
downloaded and extracted it, renaming the extracted folder to
bettercomments and placing it in user/plugins. Both gave me the same
result. After configuring the email plugin and enabling bettercomments
on the route where I want it, I still received the email, but no message
thanking me for my comment and no comment to be reviewed, approved,
denied or deleted.
I did notice when trying to uninstall bettercomments using gpm that I
got a rather lengthy error message with a trace, but I didn’t keep it.
Perhaps this is part of my problem. I am reinstalling Grav core with
admin plugin, not the Clean Blog skeleton this time, and will try
@A.Rojo, Some observations when using Better Comments…
- Installed skeleton Blog Site (which is build by Grav’s dev team and is based on Quark)
- Installed Better Comments using
$ bin/gpm install bettercomments
- Added template bettercomments.html.twig to Quarks item.html.twig
- Form appears correctly on all items below /blog
- When submitting the form:
- A temporary ‘thank you’ message appears
- A comment is saved in data/comments/blog/hero-classes.yaml
- No email is being sent
The contact form from the docs does send an email which means the email plugin is configured correctly.
- The comment is visible on the Admin page
- After approving the comment, the yaml file of the comment is updated, but comment does not appear on blog item. Manual clearing cache is required.
- Same holds when declining the comment.
- When deleting the comment:
- File is not being removed, which I would expect
- Instead, field ‘approved’ is set to 2 (which is a bit odd)
- How are ‘deleted’ comments expected to be removed? Manually using the shell?
- Refreshing the Admin page after Approve/Decline/Delete shows error “Invalid Security Token” in a red banner.
- Missing field definitions in blueprint.yaml to enable editing settings in Admin.
- It does not quite read like a book…
- Please also consider moving related code into their own classes. Eg. storage related code, admin related code.
- Not quite DRY (see eg. commentApprove, commentDecline, commentDelete)
- It does not conform the plugin style guide.
$ bin/plugin devtools new-plugin (as suggested by the docs) to create a correct plugin skeleton.
- Why is function
onPageInitialized still being used while it’s being marked as
deprecated with remark “Used by Form plugin < 2.0, kept for backwards compatibility”? Form 2.0 exists since 2016…
- The plugin is an enhanced copy of plugin ‘Comments’, which does sent a confirmation email. However, BetterComments submits the form using an async call. This means the Form plugin is no longer processed completely. Therefor no email is being send.
- This also renders other code useless
Code reviews before themes/plugins are being released are still on my wish list…
I removed my Clean Blog skeleton install and installed Grav core admin
in its place. Rather than using a skeleton, I just deleted the existing
pages and created a blog and initial post from my dashboard using the
default Quark theme, installing and configuring Bettercomments and my
email plugin. I can confirm @pamtbaau’s observations. On this install, I
no longer receive email when a comment is posted, but now I can see,
approve, decline and delete comments from the comments page, but I have
to clear the cache manually in order to see comments I have approved. I
also see the “Invalid security token” message, but reloading the page
seems to solve that problem.
Actually it seems that after clearing the cache once, I can see one more
approved comment on my post, but then I have to clear the cache again to
see another approved comment. Either that or it works intermittently.
Some comments get through, others don’t until I clear the cache.