Create sub-topics?

I would like to make some topics sub-topics of others.

Say I have “Topic A”. On the Topic A page, I will put a button to “create sub topic”. That will allow the user to create a new topic, “topic b”. topic b would be a child of Topic A.

What this means, from the user experience, is:

I could also have a button on the Topic A page to “view all the child topics of Topic A”, and this would go to a list of Topic A’s child topics, such as topic b and any other topics that are children of Topic A.

What’s the best way to do this? (I’m assuming I’ll have to do it in a plugin, which is fine.)

Note I’d only be looking for one level of subtopic down, not several.

Here’s some detail on the possibilities I think could do it:

Categories (though this probably is not the best way to go)

Categories would provide similar functionality to what I have in mind, but that could get too heavy once there are a decent number of topics with subtopics (it seems like overkill to basically have a new category for each parent topic).

or

Tags

The best I can think of right now is using tagging. So that when you click “create sub topic” on Topic A, it opens up a new topic, and I programmatically add a hidden tag, like “Topic-A”, that links to Topic A. Then when you click “view all sub topics” of Topic A, it does a search for the tag “Topic-A”.

This seems pretty clean, other than the fact that there will be a lot of tags (basically one tag for each main topic, which could end up being a lot).

or

Custom Fields for Topics

Another possibility I’ve considered is to create a custom field for topics, which would be an array of the ids of that topic’s sub-topics. This also could work, but would probably be slightly more complicated to code.

For example, I’d have to update the main topic’s custom field only after a subtopic is created; and, I’d have to create a new kind of search–searching for all the topics within the main topic’s custom field array–instead of just using the pre-built tag search functionality.

Is there another solution I’m missing?

2 Likes

I see an other solution that might work, with no heavy code work.

With the custom wizard plugin, you may do multiple actions in one procedure. So in that case, you would ask the user to write their sub-topic with a wizard that would:

  • Create a new topic for the subtopic
  • Create a replay in the main topic linking the subtopic.

With some custom CSS for all the main posts (you can add a CSS class to select them with a category or a tag), you can modify the replies appearance to match what you have in mind. You might also find a way with the wizard to add a parameter to the replies that will allow you to select only the automatic replies.

If you don’t like the reply solution, I think the custom wizard may also add the tag on the created sub-topic.

1 Like

I hadn’t thought of that. Thanks. The key piece I am missing is something in the subtopic that links back to the main topic. Such as a tag (“Topic-A”) associated with the subtopic.

Are you thinking that the wizard would, on submission, send an API call to create the tag and link it to the subtopic? (I’m not that familiar with the wizard plugin.)

I also think one limit of the wizard plugin is that it opens its own page, that does does not have the normal header of my site–in other words, I think any page with the wizard will look pretty different than the rest of the app, which could be confusing in this case for users.

I was just thinking that I would love one level of sub-topics as well. This could achieve the one level of nesting/hierarchy, while also keeping the interface clean so it’s not a bunch of nested conversations.

Examples of how I might use it:

  • Create a topic for an episode/post/article and have people create sub-topics based on their reactions.

  • Create a topic of a question and then have people create sub-topics with their own answers (bonus for option to limit one sub-topic per person)

Have you made any progress on creating a plugin or figuring out how to do this with the current Discourse features?

The only way I could see to do it was using topic custom fields. For example, the subtopic could have a custom field linking back to the main topic. Then you can do a search for all topics with that main topic as the custom field value. I don’t yet have a fully implemented plugin, but I was able to get it basically working in development using code like I mentioned here: Retrieve Topics based on custom field? - #12 by JQ331

1 Like

Ah yes, I imagine if one created a topic custom field of “topic-parent” or something like that, then there could be a lot of ways to leverage that. I’ll take a deeper look into the link you shared, and hopefully learn some Ruby along the way. Thank you!

1 Like