Number of comments limited, moderation field implemented, still not working properly on modular (child) pages
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­zung ertei­len Sie uns Ihre Ein­willi­gung zur Spei­che­rung und Ver­arbei­tung Ihrer Daten (<a href="/kontakt#datenschutz">Daten­schut­zerklä­rung</a>). Ihr Kom­men­tar erscheint erst nach Frei­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 %}
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
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.