getgrav / grav-plugin-comments

Grav Comments Plugin
http://getgrav.org
56 stars 28 forks source link

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

Open krdau opened 4 years ago

krdau commented 4 years ago

Thanks for the plugin. I really like it.

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 %}

RalfKerkhoff commented 2 years ago

Hi, I just tried your solution. Could you tell me where I "moderate" the comments. In Grav Admin i do not find where I can set a comment to published.

Thanks Ralf

krdau commented 2 years ago

Dear Ralf!

Pls. allow for a little delay: I‘m in a series of Video-Sessions all day🥴

Sorry & regards

Rainer

••• Dipl.-Ing. Kurt-Rainer Daubach E-Mail: @.*** Mobil : +49 (0) 171-328 7907 Fon. : +49 (0) 5271-391 0655 ••• "Die Erde ist nur ein Land, und alle Menschen sind seine Bürger“

Am 27.11.2021 um 19:07 schrieb RalfKerkhoff @.***>:

 Hi, I just tried your solution. Could you tell me where I "moderate" the comments. In Grav Admin i do not find where I can set a comment to published.

Thanks Ralf

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.