How to get the latest topics list from a plugin

Hello everyone,

I am editing a Discourse, and I have not found what I want to do by default. I wish that on the home page, the categories are in a first block (full width) then below, the list (detailed) of the last subjects is displayed.
The different layout options do not allow this. The closest option displays the categories on the left, and the last topics (light) on the right.

The Revolut community offers a display like this: but they are only changed to CSS the two-column view to put it in two row.

To answer my need, I realized that I could simply display the categories with the default layout, and create a plugin that hangs on “discovery-below”.

Unfortunately, I do not see how to get the list of recent topics to assign to my template in my plugin.

Do you have any ideas to guide me in my development?

Thank you


A good strategy with all modifcations is do the minimum needed: find something that exists that is closest and modify that. This is not just because we are all inherently lazy as programmers, but because you want to have the minimum exposure to risk wrt changes to the core code so your functionality has the best chance of survival with minimal changes going forward.

I hope I’ve understood your requirement correctly. In any case here goes:

I can’t go into huge detail here (as need to put dinner on the table tonight), but here’s the strategy I would employ here:

  1. Note the closest data arrangement to what I think you need is ‘Boxes with Featured Topics’. When you simply render the /categories.json in this mode you will note the data comes back in a way that is close to what you might need, that is Categories with short nested lists of topics for each Category - handy!

  2. Consider changing the featured topics method in the ruby controller to spit back the latest topics (or whatever) instead of ‘featured’:

  3. Override the template(s) for this mode to rearrange the elements in the way that you prefer. I’d take a look at this template to start with:

NB One thing to be wary of is why things are like they are already. The Category Boxes layout is designed to give you a quick view of as many Categories on the same page as possible. Having it all going linearly down the page instead may undesirably push some Categories off screen

One compromise is to just do part 2 only with no layout changes - an added bonus being it’s quicker and it’s less risky.

That’s how I’d start to go about this … you may find your strategy needs modification as you work through it.

Hope that’s helpful and gets you going. Sorry I can’t spend significant time on it at present.