Comments mystery

Hello

Im trying to get the hang of this - not being a programmer.
Working on building a quite simple catalogue site capturing information on each room i my job, a hotel.
Comments to each page would be a huge thing, giving us all opportunity to instantly report anomalities in the rooms when cleaning/fixing them for next guests.

No luck at all with trying to make it work in the theme Learning2 with git hub.
I read somewhere its because the comment plugin only works with specific “blog” template.

Then I saw the template recepta actually included the comment plugin - and it does.

But: only thing visible is a black field saying “0 comments”. Theres no input form anywhere.
I made sure all the Yaml files that seemed to be of relevance, is enabled and I typed in the “active” property too - nothing activates.

Anyone having a clue?..:slight_smile:

Thanks beforehand

@hotel If you follow the following steps, you will have Comment forms on regular pages. I use the Quark theme, but it should work on any theme. It is also not tied to any type of template.

  1. Create fresh Grav installation.
  2. Create a child theme from Quark. See Theme inheritance for guidance.
  3. Install ‘Comments’ plugin. See installation guide
  4. Copy file /user/themes/quark/templates/partials/base.html.twig into folder /user/themes/my-child-theme/templates/partials
  5. Inside the copied file insert the comments include code below line 80, resulting in the following codelines:
    80|   {% block content %}{% endblock %}
    81|   {% include 'partials/comments.html.twig' with {'page': page} %}
    
  6. Create file ‘/user/config/plugins/comments/comments.yaml’
  7. Copy contents from ‘/user/plugins/comments/comments.yaml’ into ‘/user/config/plugins/comments/comments.yaml’
  8. Alter enable_on_routes and/or disable_on_routes. This will determine where the comments forms are visible (or not). Try the following:
    enable_on_routes:
      - '/'    # This will enable comments on pages below the home page.
    
  9. If you don’t need the email field, you can block it with the following settings in /user/config/plugins/comments/comments.yaml:
    - name: email
        label: PLUGIN_COMMENTS.EMAIL_LABEL
        placeholder: PLUGIN_COMMENTS.EMAIL_PLACEHOLDER
        type: hidden    # don't show  the field
        validate:
           required: false  # Prevent validation error
    
    
    # Comment out mailing functionality
     process:
     #        - captcha:
     #            recaptcha_secret: ej32oiej23oiej32oijeoi32jeio32je
         # - email:
         #     subject: PLUGIN_COMMENTS.EMAIL_NEW_COMMENT_SUBJECT
         #     body: "{% include 'forms/data.html.twig' %}"
         - addComment:
         - message: PLUGIN_COMMENTS.THANK_YOU_MESSAGE
         - reset: true
    
  10. Point the browser to localhost/yoursite/typography and you will see the form. When you enter a comment, it will be shown below the form.

Comments are stored in files below /user/data/comments/url-of-page.yaml and can be edited/deleted using any text editor.

NB. If you prefer to use another theme, change step 5 and adapt to your chosen theme’s template.

Hope this helps…

2 Likes

pamtbaau

Thanks very much, its appreciated!!

I will try it out and return with here with result:)

Thankyou again, pamtbaau.
I got it working now, almost under control;)

Using theme “Vela” comments works out if the box, following plugins own read-me. Using theme Learn 2 with gitbox theres an issue with comments in child pages, only root related pages processes the comment. In my hands, that is.
One other issue remaining is, when I comment out the mailing functions in the comments.yaml, I get a faultpage telling me theres a indentation problem in those lines.
I wonder if these .yaml files are strict when it comes to indentations and paragraphs?