4

Is there a way to add custom fields to content comments?

For example, I would like to add a date input field and a subject field.

Alternatively could this be accomplished with the Solspace plugin "Freeform Pro 4.0.8"?

  • For clarity, you want people to be able to modified the enter date? – nonprofit_tech Dec 6 '12 at 19:17
9

There is no native way to add additional fields to the EE Comment module, no.

Freeform could work. You would have to have a hidden field that stored the entry_id of the entry being commented on, so that you could then use search:comment_entry_id="{entry_id}" when listing the comments with the Freeform Entries tag.

(Note that you'd likely have to either embed your "comments" Freeform Entries loop and pass the entry_id via an embed variable, or grab the entry_id from the URL - {segment_3} for example - in order to avoid variable collisions with the Channel Entries tag.)

| improve this answer | |
  • Can freeform entries be sorted by the value of a field? – Lea Hayes Dec 6 '12 at 19:33
  • 1
    Yup. – Derek Hogue Dec 6 '12 at 19:34
  • Nice! and would there be a way to automatically delete the comments that are associated with a product when said product is deleted? – Lea Hayes Dec 6 '12 at 19:34
  • 1
    With a custom extension, yes. You would use the delete_entries_loop hook, and then delete the Freeform entries directly from the database which had the comment_entry_id (or whatever you call your field) which matched the value of the $entry_id passed by the hook. – Derek Hogue Dec 6 '12 at 19:38
  • Ah the other thing was moderation, is there a way to add moderation to comments that are posted using FreeForm? – Lea Hayes Dec 6 '12 at 19:48
5

I would say the easiest thing to do would be to repurpose use of one of the existing fields, unless you are already using all of them. Comments can capture: name, email, url, location, and comment. I'm excluding creation and edit dates, as well as entry_id, ip_address, etc.

For example, if you are not using 'location' then use it and re-label it 'subject'.

Of course a number of sites, bypass EE's built in commenting system and use Disqus or Facebook.

| improve this answer | |
  • I didn't want to make this part of my solution, but thought it would be good idea to bring up, that most sites, really have no need to offer subjects for comments. In fact, if you want more comments, subject is more of a deterrent than an aid. That said, if you want less comments with more focus, there maybe research that suggests adding a subject/title will aid in that, but I can't say if its true or not. – nonprofit_tech Dec 6 '12 at 19:28
  • When it comes to a blog I couldn't agree more when it comes to the subject field. But in this case my client wants to use the comments as a review mechanism. The date is for the date purchased, and the subject is just the title of the review. In fact perhaps called "Review Title" instead of "Subject" as that makes more sense. – Lea Hayes Dec 6 '12 at 19:32
  • 3
    In that case, you should look at the Rating module. It offers star ratings, plus comments/reviews and custom fields for those comments/reviews. – Derek Hogue Dec 6 '12 at 19:35
  • @DerekHogue I agree that would be idea, but in this scenario if FreeForm can accomplish this it will be better because it will be cheaper. FreeForm could be used for a number of other purposes as well anyway, so if it can fit the reviews as well then that is a bonus! – Lea Hayes Dec 6 '12 at 19:45
  • 1
    I was thinking the only place I've seen subjects used for comments successfully is in reviews. In this case, I agree with @DerekHogue Solspace's Rating module is excellent. Yes, you can capture the data in FreeForm, but the Rating interface, allows you to rapidly see which items are doing well or bad, see all the ratings for a particular product, post, publication, average out ratings by reviewers, export ratings to a spreadsheet, and other things that I find beneficial. Plus, it's cheaper than FreeForm, though admittedly, you already have FreeForm. – nonprofit_tech Dec 6 '12 at 20:04
4

I would check out the Rating Module which offers "custom fields" for comments/reviews.

Edited to note: There is also DevDemon's Channel Ratings which might also be worth looking into.

Each one offers different capabilities and one might fit your needs better than the other.

| improve this answer | |
1

I'd go with a custom extension. Here's the hooks you'll need:

  • Create new database cols in exp_comments when you install the extension
  • Add additional fields to the database insert array using the insert_comment_insert_array hook
  • Then when comments are rendered use the comment_entries_tagdata hook to replace tags for the new comment fields.
| improve this answer | |
0

I've developed an add-on called Custom Comment Fields that allows custom fields to be submitted with comments (handles text inputs, textares and attachments via Safecracker File field). Datepicker not supported yet, but is in plans.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.