Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
krdau opened this issue Oct 11, 2020 · 2 comments

Comments

@krdau
Copy link

krdau commented Oct 11, 2020

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

@RalfKerkhoff
Copy link

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
Copy link
Author

krdau commented Nov 27, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants