Skip to content

Number of comments limited, moderation field implemented, still not working properly on modular (child) pages #96

@krdau

Description

@krdau

Thanks for the plugin. I really like it.

  • After some starting problems I managed to get it working on my blog pages on a stable basis (which includes regular cache clearing of my site).
  • Did some enhancements:
    • Limited the number of shown comments to e. g. 10
    • Implemented a "moderated" field to be able to control which comments are shown or not
  • Despite all efforts to get it working on modular subpages it won't work properly:
    • The comments are shown on the modular, not on the subpage
    • the path "/projekte#subpage" is changed to "/projekte/_subpage"
    • My guess: it is about the "action="…" definition

For now I have no clue what to do next. Help/ideas are heartely welcomed!
Below please find my adapted comments.html.twig:

{% if enable_comments_plugin %}
{% set scope = scope ?: 'data.' %}

<h3>{{'PLUGIN_COMMENTS.ADD_COMMENT'|t}}</h3>
<p class="small">Mit der Nut&shy;zung ertei&shy;len Sie uns Ihre Ein&shy;willi&shy;gung zur Spei&shy;che&shy;rung und Ver&shy;arbei&shy;tung Ihrer Daten (<a href="/kontakt#datenschutz">Daten&shy;schut&shy;zerklä&shy;rung</a>). Ihr Kom&shy;men&shy;tar erscheint erst nach Frei&shy;gabe. Schauen Sie daher später noch einmal herein.</p>

<form name="{{ grav.config.plugins.comments.form.name }}"
      action="{{ grav.config.plugins.comments.form.action ?  base_url ~ grav.config.plugins.comments.form.action : page.url }}"
      method="{{ grav.config.plugins.comments.form.method|upper|default('POST') }}">

    {% for field in grav.config.plugins.comments.form.fields %}
        {% set value = form.value(field.name) %}
        {% if field.evaluateDefault %}
            {% set value = evaluate(field.evaluateDefault) %}
        {% endif %}
        {% if config.plugins.login.enabled and grav.user.authenticated %}
            {% if field.name == 'name' %}
                <input type="hidden" name="{{ (scope ~ field.name)|fieldName }}" value="{{grav.user.fullname}}">
            {% elseif field.name == 'email' %}
                <input type="hidden" name="{{ (scope ~ field.name)|fieldName }}" value="{{grav.user.email}}">
            {% else %}
                <div>
                    {% include "forms/fields/#{field.type}/#{field.type}.html.twig" %}
                </div>
            {% endif %}
        {% else %}
            <div>
                {% include "forms/fields/#{field.type}/#{field.type}.html.twig" %}
            </div>
        {% endif %}
    {% endfor %}
    {% include "forms/fields/formname/formname.html.twig" %}

    <div class="buttons">
    {% for button in grav.config.plugins.comments.form.buttons %}
        <button class="button" type="{{ button.type|default('submit') }}">{{ button.value|t|default('Submit') }}</button>
    {% endfor %}
    </div>

    {{ nonce_field('form', 'form-nonce')|raw }}
</form>

<div class="alert">{{ form.message }}</div>

{% if grav.twig.comments|length %}

    <h4>{{'PLUGIN_COMMENTS.COMMENTS'|t}}</h4>
        <table id="comments">
            {% for comment in comments|array_reverse|slice(0,10) %}
                {% if comment.moderated == true %}
                    <tr>
                        <td>
                            <span class="fett">{{comment.text}}</span>
                            <br />
                            <span class="ital">({{comment.date|e}} {{'PLUGIN_COMMENTS.BY'|t}} {{comment.author}})</span>
                        </td>    
                    </tr>
                {% endif %}
            {% endfor %}
        </table>
{% endif %}

{% endif %}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions