VirtusLab-Open-Source / strapi-plugin-comments

A plugin for Strapi Headless CMS that provides end to end comments feature with their moderation panel, bad words filtering, abuse reporting and more.
MIT License
407 stars 63 forks source link

How to add custom fields to comments #80

Closed SkipTheDragon closed 2 years ago

SkipTheDragon commented 2 years ago

Hello, I would like to add an url field to the comment collection, but i don't know where to edit it (can't find it in content-types). Can i add it directly in the sql table?

cyp3rius commented 2 years ago

Hello @SkipTheDragon ,

The Comment collection is an internal one of the plugin. Anyway if you want to extend it you can simply use the Strapi Extensions mechanism.

  1. Go to plugin source: models and copy comment.settings.json
  2. Past the file into your project directory as extensions/comments/models/comment.settings.json

Read more here based on Strapi Content Manager extension: https://strapi.io/documentation/developer-docs/latest/guides/custom-admin.html#update-the-content-manager

Keep in mind that by doing your own extensions, we might be no longer able to support you with issues.

Nisthar commented 2 years ago
  1. Go to plugin source: models and copy comment.settings.json

Where is this file located? can't seems to find models directory

cyp3rius commented 2 years ago

@Nisthar As you see based on the dates, advice was for v3 compatible version :) current v4 supported by plugin in v2.x got it managed differently.

You should extend the file from content-types/comment.js using Strapi v4 extensions approach.

Nisthar commented 2 years ago

@cyp3rius when overwriting the content-type, do i have to create the schema (in schema.json) for all the fields that were already there or just the new ones?

cyp3rius commented 2 years ago

@Nisthar As that is js file you can import original one and extend proper fields by spread operator. Please follow official Strapi v4 docs for Plugins extensions.

Nisthar commented 2 years ago

@Nisthar As that is js file you can import original one and extend proper fields by spread operator. Please follow official Strapi v4 docs for Plugins extensions.

Don't i need to use .js to import or use spread operator? It seems like strapi only supports .json file

cyp3rius commented 2 years ago

Not entirely, in v4 its allowed and as you check our codebase we also support it.

Nisthar commented 2 years ago

Ok just tried it, didn't work

pasted comment.js file into ./extensions/strapi-plugin-comments/content-types/comment.js, added some fields and restarted the server. Doesn't seems to work.

cyp3rius commented 2 years ago

Let me please back to you on Monday. And also, create separated issue dedicated for v4, do not follow discussion in closed issues.

Nisthar commented 2 years ago

Let me please back to you on Monday. And also, create separated issue dedicated for v4, do not follow discussion in closed issues.

sure, i think there's no need for that now. The solution was to change the plugins name and its working 👍 EDIT: The updating only seems to capture the content of the comment (update doesnt work for custom fields)