Topic List Sort By Votes in voting plugin


(Kevin Prow) #1

We have a feature request category using the voting plugin, and the Votes sort order is available in our top menu, but is not available in the “Topic List Sort By:” dropdown in the category settings. I would love to set the default sort on this to show the highest votes at the top of the list. While I understand that sometimes a chronological view makes sense, in my use case, generating valuable feedback on the most requested features helps me to get a better picture of the benefit story for my customer base. Is there any hack I could do to make it default sort to Votes and/or is this something that is planned already for a future update?

Plugin API's design
(Sam Saffron) #2

Great suggestion, #pr-welcome

(Adrianbblk) #3


Nothing new, since then?

(Mittineague) #4

Not that it’s 100% guaranteed, but if nobody has posted a “I’ll give it a try” it can be relatively safe to assume that the “pr_welcome” is still open. Considering that it’s been 10 months, I say go for it.

(Kevin Ansfield) #5

I’ve just had a quick look at this but it appears that the Default Topic List and Topic List Sort By dropdown options are hardcoded and not available to be extended by plugins.

What are the valid/desired approaches here?

  1. Add a plugin-specific option to the hardcoded list in core
  2. Add extension points that allow plugins to add options to default topic and topic list sort dropdowns

Option 1 would obviously be the quickest to implement but I have no idea if that approach would be accepted in core (/cc @sam).

Has option 2 been proposed before? If so are any specs available?

(Kevin Ansfield) #6

Another potential option is allowing redirects for top-level category URLs. Eg:

That way the majority of links to the topic will end up on the “most-voted first” list whilst still allowing the “Latest” and “Top” menu items to work as before.

(Sam Saffron) #7

In general I much prefer (2) a more extensible core opens the door to other plugins here which is desirable.

(Kameron Bourgeois) #9

Is there a solution yet to sort by number of votes?

(Dan Ungureanu) #10

If you have no problems in getting your hands a little dirty, you can edit ./app/assets/javascripts/discourse/components/edit-category-settings.js.es6 and add “votes” to the array described in function availableSorts, like so:

  availableSorts() {
    return [
      .map(s => ({ name: I18n.t("category.sort_options." + s), value: s }))
      .sort((a, b) => {
        return >;

Now, you should see [[]] in settings.

Plugin API's design
(Elive Linux) #11

can be this included in the plugin?

(Dan Ungureanu) #12

Currently, no. The plugin API does not offer this functionality yet. It will soon. :wink: