Enable comments for blog posts?
zaszlo opened this issue · 9 comments
I would like to use the comments plugin by the grav team. It is enabled (see it from admin panel) and I see it is included in this theme in templates/partials/blog-item.html.twig:
{% if page.header.continue_link is sameas(true) and config.plugins.comments.enabled %}
{% include 'partials/comments.html.twig' %}
{% endif %}
What could be the reason that it is not appearing on the bottom of the blog posts?
Thanks!
Hi @zaszlo , I just downloaded the current Open Publishing Space skeleton (which includes the Quark Open Publishing theme) and installed the Comments Plugin and it seemed to work:
UPDATE: Doing some more testing it seems that some posts display comments and some do not... looking at the original Quark theme it has the same issue. Try changing that original code chunk to the below and please let me know if it works as expected:
{% if config.plugins.comments.enabled %}
{% include 'partials/comments.html.twig' %}
{% endif %}
BTW, looking at the Antimatter theme I am unsure why in Quark page.header.continue_link is sameas(true)
was added.
Thanks for the feedback, tried with the modified snippet, but still the comment section didn't appear... any other hints on how to debug what is going on?
Did you clear the cache for your test (system.yaml file, both caches or via Admin Panel)? Also confirm that your active theme is the theme file you are editing - thanks!
I did clear the cache with method "all" and am using the My Quark Theme with only minor additions in templates copied from Quark Open Publishing:
item.html.twig
partials/blog-item.html.twig
partials/navigation.html.twig
The partials having the edit that you suggested here. But did that edit on both My theme and on the Quark Open Publishing.
...
{% else %}
{{ page.summary }}
{% endif %}
</div>
{% if config.plugins.comments.enabled %}
{% include 'partials/comments.html.twig' %}
{% endif %}
</div>
{# added check for content display flag - hibbittsdesign.org #}
{% if not (grav.uri.param('chromeless')) %}
...
Interestingly if I add
{% if config.plugins.comments.enabled %}
OK
{% include 'partials/comments.html.twig' %}
{% endif %}
The OK is rendered fine. I installed the comments plugin from admin console and checked that it is enabled, did not touched it otherwise.
Hmm... I've made a new release of the theme with the above fix, perhaps try that?
I've also released a new Open Publishing Space skeleton with the new theme, you could download and test that with the Comments Plugin to make sure there are no issues with your specific setup etc. https://getgrav.org/downloads/skeletons
It was my bad that I didn't created a new comments.yaml into my config/plugins and didn't changed the default enabled route from blog to home.
Glad you got things going!
Hi Paul,
I'm tested Open Publishing Space skeleton with the Comments Plugin.
I got this error:
Whoops \ Exception \ ErrorException (E_NOTICE)
Trying to access array offset on value of type null
I copy the contents of user/plugins/comments/comments.yaml
in user/config/plugins/comments.yaml
.
However, I notice that there is no user/data/comments
folder. This seems normal to me because there are no comments on the articles.
It seems the error is in the "comments" plugin: Issue #81 Grav 1.6.19 on PHP 7.4.1 is broken (again?)
I applied PR #82 Fix error when there is no comment. That seems to be okay.
Thanks for letting me know @LeMoussel 🙂