Categories Topic Replies

AI-generated summary

In the Dev category, user ShankarG seeks guidance on building a Discourse plugin to allow users to assign custom categories and sub-categories to individual replies, rather than just topics. ShankarG, who has experience with PHP/Laravel and is learning Ruby on Rails and Ember.js, initially proposed a UI where reply inputs include category selection. Mittineague questioned the intent, noting that standard Discourse categories are hierarchical and only apply to topics, not replies. Falco clarified that ShankarG effectively needs custom fields per post, which is achievable but requires significant plugin development. mikechristopher suggested using tags as an alternative. ShankarG confirmed the custom field approach and requested specific documentation or code samples on how to store, update, and display these fields using PluginStore and the client-side API, as the existing Beginner’s Guide to Creating Discourse Plugins does not cover these specific functionalities. ShankarG noted that despite reviewing the guide, they still lack clarity on injecting custom fields into the post view and managing data persistence.

I’m new to Ruby on Rails and Ember js(but have programming knowledge and working on PHP with laravel and also have experience with JavaScript). My requirement is while posting reply to a topic the user will select category and sub-category(e.g: if topic is about a particular smart phone, then the replies are categorized like Connectivity >> Wi-Fi, Battery >> Capacity and soon).

The reply window will be like below image

and it will be displayed like below

I have started developing plugin for this and stuck after starting. Currently I’m studying both ember and ruby on rails. Can someone explain if it can be implemented with plugin and methods and technique for implementing.

Hi ShankarG welcome to the forum

I’m a bit confused as to what your intent is.

I think of Category - Topic → Post as being kind of “top down”, “parent - child”, or “has many - has one” type of relationship.

Your first mock-up has separate inputs for Category and Sub-Category. Currently, Sub-Categories are just Categories that have a parent Category.
And there is only one input that is only available for New Topic, not for replies to an existing topic.

Your second mock-up shows the category breadcrumb in a posts topic meta data. Currently this information shows in headers not per post.

Can you please explain more as to what you are wanting to do and why.

I imagine it would be possible to do with a plugin, but there may be different ways to approach whatever it is you are wanting to do.

If the aim is categorisation in terms subjects as per you explained earlier it might be wise looking at using tags

Looks like you want category and subcategory per post.

So you don’t want categories at all, better call it custom field 1 and custom field 2, per post.

This is doable with a plugin, but will take some work.

Thank’s for you reply, You got my concept clearly and also I have planned to implement it with custom fields for post and PluginStore.

As I’m newbie to ember and rails, I didn’t know how to store, update, read, display the custom fields from plugin and to work with PluginStore. Can’t find documentation in Beginner’s Guide to Creating Plugin for there function.
so it would be helpful if you can provide related guide and sample code if any.

Also there is no plugin outlet inside post and also client side plugin api have only before and after post methods, so how to inject those custom fields into post.

My concept is as @Falco describe, [quote=“ShankarG, post:5, topic:49782”]
As I’m newbie to ember and rails, I didn’t know how to store, update, read, display the custom fields from plugin and to work with PluginStore. Can’t find documentation in Beginner’s Guide to Creating Plugin for there function.
so it would be helpful if you can provide related guide to do it.
[/quote]

it may help:

I have gone through this guides (all 5 parts), but none of this explains working with store, update display using custom fields for post and PluginStore(used by plugins to store data in DB).