verbb / comments

A Craft CMS plugin for managing comments directly within the CMS.
Other
137 stars 33 forks source link

Comments history in comment detail view #265

Open yingban opened 1 year ago

yingban commented 1 year ago

What are you trying to do?

Hi,

One of our clients would like to have the comments history inside a comment detail view if it is answer to another comment.

What's your proposed solution?

I did something ugly in the "_edit.html" file for testing purpose, with

in case there might be many.

`{% set parents = craft.comments.fetch() .ancestorOf(comment) .all() %}

{% if parents %}
  <div class="field">
    <details>
      <summary class="heading">{{ 'Reply from comment(s)' | t('comments') }}</summary>
      <ul>
        {% nav parent in parents %}
        <li{% if not loop.first %} style="margin-left: 10px;"{% endif %}>
        &#x21AA; {{ parent.comment }}
        {% ifchildren %}
        <ul>
          {% children %}
        </ul>
        {% endifchildren %}
        </li>
        {% endnav %}
      </ul>
    </details>
  </div>
  <hr>
{% endif %}`

Would you have any suggestion for improvement?

Additional context

Screenshot 2022-10-07 at 17 27 39
engram-design commented 1 year ago

Would this be different to the current "Replies" section, where you can see the replies on a comment? Or more the other way around (on a reply, show the parent comment)?

I think what you've done is fine! I'm not sure how useful it'd be to see the hierarchy of other comments for everyone else (that's what the comments index is for), so some custom templating as you've done makes a good fit.

yingban commented 1 year ago

I'll try to make it look like more the "Replies" section. Indeed, it is more the other way around, before approving the comment, the moderator would be able to see the parents comments, to have the context before deciding.