הוספת עמודה לרשימת נושאים

סיכום מבוסס בינה מלאכותית

A user asks if they need both a theme component and a plugin to add a column to the topic list on the homepage, noting they need to override two templates. RGJ confirms the templates are correct and explains that a theme component alone can handle the override if the required data is already in the topic list JSON. If not, a plugin is needed to serialize the data, as demonstrated by the Discourse Topic Author theme component.

Hi,

I’d like to add a column to the topic listing shown on the homepage. Do I need to create both a theme component and a plugin to accomplish this? This entails overriding both app/assets/javascripts/discourse/app/templates/topic-list-header.hbr and app/assets/javascripts/discourse/app/templates/components/topic-list-item.hbs to the best of my knowledge. If possible, I’d like to do this in a self-contained plugin rather than requiring a separate theme component.

I’m new to Discourse so any pointers would be much appreciated!

Yes. those are indeed the templates you will need to override.

You don’t need to create both a plugin and a theme component.

You can override both templates from within a theme component. A good example is the Discourse Topic Author theme component.

But you can only use a theme component for this if the desired information is already present in the json for the topic list. If it’s not, then you will need to use a plugin that does not only override the theme components but also serializes the information to the json.