Comments functionality questions
Created 6 years ago by emergingdznsI'm working on integrating the comments module on a module I've built. I need to find out if the following are possible with the module as it is now or do I have to extend it?
- Would like to be able to query comment count on a subject. I just want to be able to have it say something like "5 Comments" on a list page for the subject, but not the full comment list and form.
- Would like to override the gravatar image to use an image the user will be asked to update in their account using our module.
- Would like to include the comment form on the subject full details page by using
{% include "anomaly.module.comments::comments" with {'subject': item} %}
BUT also wanting to tell it to auto approve the comment for all users. We want to skip all moderation for now.
Thanks!
You rock Ryan. Thanks!
Ok so one more question... Is there any api functionality here where I can create my own form layout and submit the comment without using the comment form builder? My client wants a comment field that is more like the Facebook setup where it's a single line entry but we'd be using the bootstrap input-group to have the text field and button in one row. So I'm sure I need to custom build this but I need to know how to submit the comment, ideally via ajax call. Or would I need to have a controller in my own module that uses the discussion and comment repositories/models and inject it manually?
I have partially answered my own question there. I realized I could do set form = form('comments')....get() etc and then make the form the way I want it 😄. However I would love to know if there's a way to submit it via AJAX instead of reloading the page.
This is all certainly doable!
https://pyrocms.com/documentation/comments-module/1.0/usage/discussions#basic-use
1.) Something like
{{ subject.discussion.comments().count() }}
should do it (notecomments()
and notcomments
the prior returns a relation the latter returns a collection).2.) You can override all the views as needed: https://github.com/anomalylabs/comments-module/blob/1.0/resources/views/comments/partials/comment.twig
3.) You can specify default approval state from the view as well just pass in
'approved': true
along with the subject.