I used https://github.com/Addpixel/KirbyComments, the plugin of Florian in many websites until today. The new Kirby v3 looks gorgeous to me and I installed it. After a not-that-easy process, i got it working - besides the Comments Plugin. It not just doesn’t work, it even breaks the translation stuff.
Does anybody have an idea what’s the main problem of that plugin or can provide me with an actually working Comments Plugin for Kirby v3? Maybe @florianpircher can help me here?
The way plugins work for Kirby 3 is completely different to Kirby 2, so plugins need updating before they will work. You would need to wait for Florian to update it, or have a go your self, but it is a complex plugin so that may take a while.
I have look into updating the plugin for Kirby 3, but had to conclude that updating the plugin would be more work than I am willing to put into the project. The plugin API has changed significantly with Kirby 3. Updating the plugin with all of its functions and options for the new API would require a complete rewrite of the software and its documentation.
Updating just the core functionality would actually be doable within a reasonable timespan, but then I would have to remove many features and options that are more difficult to translate to the new Kirby 3 architecture. If you are familiar with PHP and the new plugin API, you can look at comments.php of the plugin and try to update only the parts that you need and delete the rest. I am happy to help if you have any questions about the internals of the plugin.
Because comments are saved as subpages, you can write your own snippet for rendering comments. That way you don’t loose the existing comments on your page.
@florianpircher Ugh, yeah I thought so… I’m familiar with PHP, but neither with the new plugin API, nor the old one… But maybe i’ll try to play with it a bit… Thanks for offering your help!
I have a few questions about getting this to work on Kirby 3.
plugins/kirbycomments: The instructions say to add this into the plugins directory, but Kirby 3 doesn’t natively come with a plugins directory. Will adding a directory /site/plugins actually work when adding the ‘kirbycomments’ directory into ‘/site/plugins’?
Where should the following files be placed in a Kirby 3 install: index.php, package.json
Yes that will work. Kirby does not ship with any plugins, but it’s fine to manually create the folder and manually install plugins into it. The best way is to use composer, but this particualar plugin does not seem to be up for that, yet.
According to the read me, the downloaded files should go in…
site/plugins/kirbycomments/
So that everything goes in that folder, don’t put it in a sub folder.
Thanks @jimbobrjames – this does get the field to render, and the “preview” to render, but when submitting the comment I get an error. The result of which is here – It seems to be unable to create the comment file. I am wondering if it has to do with one of two issues:
It’s unable to access the YML file because it’s currently in the “plugins” directory (see screengrab).
There is some inability to the plugin to write to the appropriate content directory? Perhaps I have to update the path reference or give the plugin some write permission?
Thanks of course for any help.
Screengrab of my directory structure and of the error.
Hm, looks like $comments_page is not created in the first step. The yaml file is not important in this context. Can the Panel write to the content folder?
Hi @texnixe – if by asking “Can the Panel write to the content folder?” meaning does the panel allow me to publish, it does. You can see where I am with things here if that’s helpful – http://lostarts.xyz/craighton-berman/critique-1
This is the URL that produces the error in the example above, after fully submitting the comment.
Hm, I don’t see how that error message is related to the comments page? The error I see there is caused by calling the avatar() method on a user when there is no user… There should be two if statements here:
Hi @texnixe thanks for digging in. I started investigating before you added the code block above. Is that code block in reference to the comments page ($comments_page) or is this related to the page causing the error “critique.php” (the template for this page)?
btw: I commented out much of the code in my critique.php, including my previous call to $avatar and user, and I’m still recieving the same error… hence the clarifying question above.
Per @texnixe comments I’ve gone through the resulting error (same as the screenshot above), as well as completely deleted majority of the contents of my critique.php template so the only thing that renders is the Header and Footer snippet along with the snippet for Comments.
Unfortunately I get the same error, and so it leads me to wonder, @texnixe are you seeing a different error than what I shared above?
Also in that screenshot error message it’s indicating the error is coming from:
/nfs/c01/h06/mnt/6643/domains/lostarts.xyz/html/site/plugins/kirbycomments/plugin/Comments.php
No, after the form was online I filled in the form and tried to submit, which then resulted in the same error message your originally posted above.
Somehow the parent folder is not created (the plugin should actually make sure there is a $comments_page before calling the createChild() method, but doesn’t. That would at least prevent the error.
Edit:
Ok, I had a closer look at the plugin code and there are at least three issues:
It doesn’t authenticate before trying to create the $comments_page page.
The code for creating the page is not correct, either (that is still Kirby 2 code, I think)
It doesn’t check if the parent page was successfully created before trying to create the comment children
Ha! I might have stumbled (though much more clumbsily) into a similar realization. I manually created a “comments” directory in the ‘content//’ directory and the comments stuck and I didn’t get the error (which I believe pertains to your points #1 and #2 above).
@RastaTux any thoughts based on your updating of the plugin?
Or any suggestions for another commenting option? Ideally something as simple as this one
I see what you’re doing here… cool. So I’ve gotten this input as you’ve suggested, but a new error has unfolded on line 495 below. Error and code…
Error message:
Parse error: syntax error, unexpected 'public' (T_PUBLIC) in /nfs/c01/h06/mnt/6643/domains/lostarts.xyz/html/site/plugins/kirbycomments/plugin/Comments.php on line 495
Code below:
/**
* `true` iff no comment is managed by this `Comments` instance.
*
* @return bool
*/
public function isEmpty()
{
return count($this->comments) === 0;
}
I went through to see if all ‘{}’ and ‘[]’ and ‘()’ are properly closed. Perhaps I’m missing one? This error seems to break both the Panel and the site itself.