Comment replies aren't being posted

In my migration from wordpress, I’ve set up my test environment.

I’m using the “Blog Site” skeleton (and to be honest, no matter how much googling I’ve done I still don’t know what skeleton means and why someone would choose that versus a whole theme).

I’m using the “Better Comments” plugin.

I made a comment on this page and that comment displays fine.

I used the Grav Admin to “answer” the comment and it created a new yaml file here…

user/data/comments/blog/using-nx-and-tail-number-sizes.yaml

and the contents of that file look like this…

title: 'Using NX and Tail Number Sizes'
lang: false
comments:
    - { text: 'This is a reply to the first comment.', date: 1684726981, author: DJ, email: myemail, approved: 1, answer: 1684477488 }

This is where my inexperience plagues me. I’m sure the fix is simple, but I can’t figure out why the reply isn’t being displayed. I’ve mirrored the test site on my MAMP and the same thing is happening so it’s probably a template issue. Any input is greatly valued. I’m not giving up.

1 Like

@Alpha,

According to Google skeleton means:

  1. the supporting framework, basic structure, or essential part of something.
    “the concrete skeleton of an unfinished building”

Anyway, I cannot reproduce your issue. The plugin seems to be working as expected.

  • Fresh install of skeleton Blog Site
  • Installed BetterComments: $ bin/gpm install bettercomments
  • Added {% if config.plugins.bettercomments.enabled %} {% include 'partials/bettercomments.html.twig' %} {% endif %} at the bottom of /user/themes/quark/templates/partials/blog-item.html.twig
  • Opened browser and added a comment to page http://blog-dev/blog/hero-classes.
  • The file /user/data/comments/blog/hero-classes.yaml got created with the following content.
    title: 'Body & Hero Classes'
    lang: false
    comments:
      - { text: 'A comment form pamtbaau', date: 1684732311, author: pamtbaau, email: 
    pam@tbaau.com, approved: 0, answer: 0 }
    
  • Opened Admin in the browser and opened menu Comments
  • Approved the comment just created
  • Added an answer
  • File now contains:
    title: 'Body & Hero Classes'
    lang: false
    comments:
      - { text: 'A comment form pamtbaau', date: 1684732311, author: pamtbaau, email: pam@tbaau.com, approved: 1, answer: 0 }
      - { text: 'And this is the answer to my own comment', date: 1684732518, author: xyz, email: q@q.com, approved: 1, answer: 1684732311 }
    
  • Refreshed the page with the blog item which now shows:

There’s one major difference between our results. Your comments and replies are being created in a single file. Mine are not.

The first comment gets created here:

`user/data/comments/filename.yaml`

The reply comment gets created here:

`user/data/comments/blog/filename.yaml`

So in addition to the files being created in different locations, they’re both formatted very differently.


The first comment yaml file looks like this:

title: 'Post Title'
lang: false
comments:
  -
    text: 'This is the first comment.'
    date: 1684477488
    author: Dorian
    email: myemail
    approved: 1
    answer: 0

The reply comment yaml file looks like this:

title: 'Post Title'
lang: false
comments:
    - { text: 'This is a reply to the first comment.', date: 1684726981, author: DJ, email: myemail, approved: 1, answer: 1684477488 }

PS: Thanks for the google skeleton definition, though I still don’t know why someone would use a skeleton rather than a full theme. Just not able to wrap my head around that.

@Alpha, I did not alter any settings. Did you?

In reply to:

Sometimes Google is not one’s best friend. Maybe you’ve overlooked the introduction text on the Skeleton Downloads page which quite clearly explains what a Grav skeleton is:

A Grav skeleton is an all-in-one package containing the core Grav system plus sample pages, plugins, configuration. These packages are a great way to get started with Grav.

Simply download the ZIP file, extract it in your web-root, and you are ready to start using Grav!

When asked, ChatGPT amongst other things describes a Grav skeleton like so:

Using a Grav skeleton allows you to quickly set up a website without starting from scratch. It saves time by providing a solid starting point with essential files and configurations already in place. It also serves as a learning resource, demonstrating best practices and offering examples of how different components of a Grav site can be structured and organized.

Not a bad description at all I would say. Besides if you do a search on this forum you’ll get over 50 results about “skeleton”. Of course not all are great learning resources but together these posts will also help you get a better understanding of skeletons and Grav in general.

Not that I’m aware of. Off hand, do you know what setting would make comments go into one directory and replies go into another?

@Alpha, Please try the steps I’ve shown and see what happens.

Off hand, do you know what setting would make comments go into one directory and replies go into another?

  • What would be the use-case for that?
  • If there is no such setting in the README, or in the plugin’s blueprints.yaml file I guess there is none.

I set everything up according to the instructions.

I just deleted the plugin and reinstalled it and the same thing is happening. The first comment gets created at user/data/comments/file.yaml and the reply via the admin gets created at user/data/comments/blog/file.yaml and only the original comments get displayed on the page. Everything that is replied to via the admin do not get displayed on the page.

It’s not making any sense. :slightly_frowning_face:

Could this in any way be caused by using a skeleton rather than a theme?

@Alpha,

Could this in any way be caused by using a skeleton rather than a theme?

That doesn’t make sense because I’ve shown in my steps that I’m using the Site-Blog skeleton.

I also see that you’re using the plugin on the root page of the blog. Please try to add the plugin to the template of a blog item instead. In Quark, that would be /user/themes/quark/templates/partials/blog-item.html.twig

I set everything up according to the instructions.

I’ve suggested to repeat my steps, not the steps mentioned in the README of the plugin. What happens when you follow the instructions I’ve mentioned?

I’ve followed your steps and continue to get the exact same results.

I removed {% include 'partials/bettercomments.html.twig' %} from
user/themes/quark/templates/item.html.twig

and added {% if config.plugins.bettercomments.enabled %} {% include 'partials/bettercomments.html.twig' %} {% endif %} to the bottom of
user/themes/quark/templates/partials/blog-item.html.twig

The same things happens.

Any comment that is created via the website creates a file here user/data/comments/filename.yaml
and those comments will display on the page.

Any comment that is created via the admin creates a file here user/data/comments/blog/filename.yaml
and those comments don’t get displayed.

At this point, the only thing I think I’ve done different than you was to install the plugin via the admin whereas you installed it via the command line.

FWIW

  • all of my pages have been created in user/pages/01.blog and use item.md
  • the site’s home page is set to that “01.blog” directory
  • the Hide Home Route in URLs is set to YES

@Alpha, Based on some remarks it seems you did not start off with a clean slate of ‘Blog Site’ skeleton as I did.

Apart from that, I’m out of suggestions.

The plugin in question is actively maintained. (A pull request has been merged this week.)

You could create an issue in that repository and report your problems there.

Good news! I discovered the problem, but unfortunately I don’t know how to fix it and have “clean” URLs like my wordpress site.

This entire issue is caused by the site admin configuration option “Hide Home Route in URLs” being set to YES.

When it’s enabled, then the site URLs look like
yoursite/page-name
(which is what I want)

When it’s disabled, then the site URLs look like
yoursite/blog/page-name
(which is what I don’t want)

This explains why comments being made on your (pamtbaau’s) test site were put it in a comments/blog directory, whereas for my setup it was putting everything created on the front end in the comments directory and everything created via the admin in the comments/blog directory.

So, does anyone have a solution that would allow me to have URLs that look like
mysite/page-name AND work with the Bettercomments plugin?

@Alpha, The issue is caused by the plugin. Its javascript running in Admin (user/plugins/bettercomments/admin/assets/bettercomments.js) uses a hardcoded '/blog/' on line 61 to prefix the filename to be used for the answer.

file = '/blog/' + $('td#comment-' + commentId).data('file-name').replace('.yaml', '')

Replacing '/blog/' with '/' will solve the issue in your use-case. The plugin should add some logic to fix the issue for generic use-cases.

You might want to report this in the issue you’ve created at the repo of the plugin.

NB. It’s useful to share any issue created on a repo with the community. This allows anyone to follow the outcome of this post in the issue.

Also if I had known about the issue prior to my research, it would have saved me the trouble. In general, it is not really appreciated if a question is asked in multiple locations (eg. forum and github).

Lastly, it would be kind to the developer of the plugin, if you could provide a succinct summary of the problem instead of forcing the developer to dig through a thread of 14 posts to figure out what the issue is.

I didn’t know what I was doing was wrong. I asked the plugin author if he could provide some input over here and provided him a link to the post that I thought would most accurately help him understand the scenario. It never occurred to me that it would be necessary to let the group here on these forums know that I reached out to him. I don’t know what to say. Sorry. :slightly_frowning_face: I’m totally new to grav and github and didn’t think that I was doing anything that would cause problems for people especially you because you’ve been helpful. I’ll try to do better.