Create multiple custom fields for a topic

Hello,

I was wondering if anyone has created multiple custom fields for a topic? I was able to use this plugin successfully to create one custom field: GitHub - pavilionedu/discourse-topic-custom-fields: Discourse plugin showing how to add custom fields to Discourse topics

However, I am having trouble creating multiple custom fields. Does anyone have a working code example that would be willing to sell or share with me? I can modify it to meet my needs but just need a little help getting started. The 2 new fields I would need would be price (string) and url (string). I would love to also add an image upload field to the topic but have yet to see anything like that.

Thanks!

Hello,
I would be happy to help you. I recently created a plugin where I utilized topic custom field (Discourse Chain Topics Plugin).

In my plugin I created an extra two fields for each topic of type of integer. Similarly you could add as many fields as you want. In the end topic/user custom fields, is a JSON object where each field you add will be then be as a key/vale in the JSON obeject . where key is the field name and value is the value.

The example you brough above (which also helped me as well) is built such that you add extra field in admin panel, where you choose its type and name. However you don’t necessarly have to relate the extra fields to admin panel. Simliary you could add as many fields as you want (Not suer how this might affect the performace).

Lastly feel free to ping me/ message for any support you need. You can also find my conact details at https://ghassan.blog
Which you best of luck.

3 Likes