Creating a custom filter homepage

Can I create a dynamic homepage like this:

  • 10 Recently Active Topics (this week)
  • 5 Latest Created Topics (today)
  • 5 More Recent Topics (this week)
  • 5 Most Replied Topics (this week)
  • 5 Most Liked Topics (this week)
  • 5 Latest Created Topics (yesterday or today)

There’s a theme component through which I can create a homepage like this in Discourse Filtered Topics List, but I feel the drawback is that it only works with a certain timeframe, so I would have to change the timeframe daily.

I mean, for now, it works on a basis that I can add dates to it, like:

activity-before:YYYY-MM-DD topics with latest bump before specified date
activity-after:YYYY-MM-DD topics with latest bump after specified date
created-before: YYYY-MM-DD topics created before specified date
created-after:YYYY-MM-DD topics created after specified date

But then I would have to always change dates. Is there any alternative I can do in the forum?

2 Likes

Also, the major issue with this component is that it repeat topics in every sort

Does your case require these to be literally most replies/likes? If you use the /top topic list you can get automatic time periods… top factors in views, likes and post count (and you can adjust these weights a little bit with site settings)

Right this is a complication with sourcing multiple topic lists, a component would need to cross reference each list and remove duplicates. Not very complicated, but I don’t think this has been implemented in any available components.

1 Like

Not entirely on replies and likes but yes, just trying to create a dynamic looking homepage.

So, a component which can remove the duplicate topic from either of the field will do the work?

Yeah it wouldn’t be too complicated to add a “hide duplicates” feature to Filtered Topic Lists, if @gormus is interested. The findFilteredTopics action could be modified to store every topic ID in a list, and then duplicates could be filtered out.

The downside is that if you want a list of 10 topics, you might only get 5 after duplicates are removed… but that could be partially avoided by maybe fetching a few extra beyond what was specified in the setting.

1 Like

I’ve added filtered lists to homepages on several projects before and I’d caution that to populate multiple “most recent” lists with overlapping filters, you really need a very active community to begin with. Now when your community is that active, you’ll also have a much richer set of content to work with for building a dynamic homepage. In that case, a block of different lists might rather come off as static and not so visually appealing.

Though for a slightly different angle, you could also explore just putting one or two lists with a manual time filter. That could even feel more dynamic for the users. As in this view:

That’s a feature I took from the Central theme and it’s available here as a block component: Manuel Kostka / Discourse / Blocks / Top Topics · GitLab

3 Likes

True, this might work but however I actually wanted to populate multiple filters on the page.

2 Likes

Yes, that actually works. If @gormus would be interested :))

I’ve made an update today that will help with this a little bit: FEATURE: allow date-based filters to accept a day count by awesomerobot · Pull Request #33197 · discourse/discourse · GitHub (you should get this the next time you update Discourse)

This will allow you to enter your desired number of days into the activity/created-before/after filters, so you can do:

activity-after:7 topics active the last 7 days
created-after:1 topics created after 1 day ago

You can also use 0 for today (as in after midnight)

4 Likes

Damn, that was quick. Thank you!!

2 Likes