Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Gantry

Unable to display Comments plugin in Gantry 5 Helium theme

Started by Dima 2 years ago · 2 replies · 74 views
2 years ago

Hi everyone,

I'm trying to add comments to articles in GRAV CMS (latest version) using the Gantry 5 Helium theme (latest version) and Comments plugin. I've encountered some issues getting the comments to display.

Current setup:

  • Latest GRAV CMS
  • Latest Gantry 5 Helium theme
  • Latest Comments plugin (installed and enabled)

What I've tried:

  1. Adding comments via Custom HTML particle in Gantry admin:

    TWIG
    {{ grav.twig.comments|raw }}
    

    and

    TWIG
    {{ grav.twig.render('partials/comments.html.twig', {page: page})|raw }}
    

    and

    TWIG
    {% if config.plugins.comments.enabled %}
    {% include 'partials/comments.html.twig' with {'page': page} %}
    {% endif %}
    
  2. Debugging shows that neither config nor page objects are available in the particle context (tried {{ dump(config.plugins.comments) }} and {{ dump(page) }} - both empty).

  3. Checked for template files:

    • No blog-item.html.twig in /user/themes/g5_helium/templates/partials/
    • No relevant templates in /user/themes/g5_helium/particles/
    • Only YAML files present in /layouts and /blueprints

Questions:

  1. What's the correct way to integrate Comments plugin with Gantry 5 Helium theme?
  2. How can we access the GRAV page context within Gantry particles?
  3. Is there a specific template override needed for the Helium theme?

Any help would be greatly appreciated. Thank you!

2 years ago

@Dima:
Any help would be greatly appreciated. Thank you!

I would love to have more time to help you, but right now it is impossible. However, I can tell you that in Gantry you have to specify the content inside the {% block particle %} blocks, and the content of the .yaml file is called with particle.xxx (where xxx is a variable specified in .yaml).
For example, the particle sample.html.twig in its .yaml file has this:

YAML
name: Sample Content
description: Displays Sample Content
type: particle
icon: far fa-edit

configuration:
caching:
type: static

form:
fields:
enabled:
type: input.checkbox
label: Enabled
description: Globally enable the particle.
default: true

image:
type: input.imagepicker
label: Image
description: Select the main image.
overridable: false

Look how it calls the image variable inside the twig file:

TWIG
{% block particle %}
....
....
{% if particle.image %}<img src="{{ url(particle.image) }}" class="logo-large" alt="{{ particle.headline|e }}" />{% endif %}
....
{% endblock %}

That is, to integrate the comments plugin content, you may need to make some custom settings to some particle, or create your own particle for it.

Check out the official documentation:
https://docs.gantry.org/gantry5/advanced/creating-a-new-particle

2 years ago

BTW, the Grav comment plugins are quite outdated. We'll have to take a look at it to see if it's still compatible with new versions of Grav.

Gantry is also in a stagnant development phase, but I hope to see new versions and bug fixes soon.

Volunteers needed!!

👍 1

Suggested topics

Topic Participants Replies Views Activity
Gantry · by Chris, 11 months ago
1 171 11 months ago
Gantry · by Sam, 1 year ago
7 220 1 year ago
Gantry · by KimTaeWoong, 9 years ago
2 1882 3 years ago
Gantry · by stani, 6 years ago
2 829 3 years ago
Gantry · by Owain Catton, 4 years ago
3 594 4 years ago