Addpixel / KirbyComments

[Kirby 2] File-based comments stored as subpages for the Kirby CMS.
MIT License
68 stars 5 forks source link

Comments not being created #6

Closed chrisallick closed 7 years ago

chrisallick commented 7 years ago

Hello, I've downloaded the zip and moved it to plugins. I used the snippet on one of my pages, but when I submit the comment it does not appear in the panel.

First thing I checked was to see that my page did allow subpages, so I set pages to true. Also made sure to check permissions of the newly added plugin set to read & write.

I also noticed the button said "preview" but still submitted. So I just commented the snippet to just "submit."

Not seeing any comments in panel. Any thoughts on what I'm doing incorrectly?

chrisallick commented 7 years ago

Alright, figured it out. I had some javascript that was handling the a form submission and was stopping the event from propagating. AJAXing out this whole thing would be nice so that page doesn't refresh.

florianpircher commented 7 years ago

Kirby Comments requires you to preview your comment before submitting it. This method has two advantages over direct comment submission:

  1. It prevents spam-bots from commenting on you page.
  2. Users get to see a rendered version of their comment before submitting it.

Not seeing any comments in panel.

Are you seeing any comments on your website or are there comments files stored in content/your_page/comments

chrisallick commented 7 years ago

Got it all working. I'm using the plugin to record user emails who want to sign up for a newsletter. So I'm sort of just getting the lay of the land of how the plugin architecture works and how you can use PHP to put files back into the flat-file system.

Appreciate the follow up. Great plugin.

florianpircher commented 7 years ago

I have never tried to implement this plugin using AJAX, but it should be possible nonetheless.

Some ideas:

Submitting and rendering comments is handled by the comments object.

<?php $comments = new Comments($page); ?>

In order to process the HTTP POST data, you have to call its process method.

<?php $status = $comments->process(); ?>

You could do this in a separate Kirby Template (e.g. comments-ajax.php). This template would simply return the updated markup for the comments list and form. Most of what you need can be found in the example comments snippet. On the client side, you would replace the list and the form by the new markup, which was requested via AJAX.