This is a collection of education plugins that demonstrate how to add a custom field to different models in Discourse. They are intended as learning tools for those looking to learn how to build discourse plugins.
How to add a custom field to a topic
How to add a custom field to a category
Who they’re for
These plugins are for people looking to learn more about creating Discourse plugins. Before you start working with these plugins, you should complete the beginners guide to creating discourse plugins.
You could use these plugins just to add a custom fields on your Discourse instance, however you would still need to change the code slightly to do so. It’s not designed for plugin-and-play use on a live server.
How they work
As well as containing working code, each plugin contains a step-by-step description of what the code is doing in the form of comments. For example
##
# type: step
# number: 1
# title: Register the field
# description: Where we tell discourse what kind of field we're adding.
# You can register a string, integer, boolean or json field.
# references: lib/plugins/instance.rb,
# app/models/concerns/has_custom_fields.rb
##
register_topic_custom_field_type(FIELD_NAME, FIELD_TYPE.to_sym)
Hopefully the steps and comments are self explanatory. The references
are there to show you where to look if you want to learn more.
Let me know if you find it useful, if something isn’t working, or the notes are unclear