Category's sorting


So is there an easy way to change how category sorts all the topics by default? I think it would be pretty neat to do this. For example sort one category by topic views and other by likes etc. And again I mean by default so user shouldn’t have to click anything.

(Nathaniel Mattocks) #2

Sounds like a good idea, might be done in the future hopefully! :slight_smile:


I figured kind of cheesy solution to this.

Replace the line “json.topics = topicsFrom(json, store);” with this code at the end of discourse/models/topic-list. Change the “blogs” to your category slug and change the “created_at” to the attribute you want to sort it with and reverse just changes it to descending. Maybe this is useful to some.

[quote]if (json.filter == ‘c/blogs/l/latest’) {
json.topics = topicsFrom(json, store).sortBy(‘created_at’).reverse();
} else {
json.topics = topicsFrom(json, store);
} [/quote]