comments icon indicating copy to clipboard operation
comments copied to clipboard

Comments history in comment detail view

Open yingban opened this issue 3 years ago • 2 comments

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

yingban avatar Oct 07 '22 15:10 yingban

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.

engram-design avatar Oct 08 '22 03:10 engram-design

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.

yingban avatar Oct 08 '22 08:10 yingban