Topic List Sort By Votes in voting plugin

Any idea for when the plugin API will offer the functionality to let sorting by votes be included in the plugin?

Hoping “soon” is soon. :smiley:

I have added the required plugin API in discourse#7158 and used it in discourse-voting#38.

Sorry for taking me so long. :cry:

9 лайков

This is awesome, sorting by votes is now an option, but is there any way to make it a category default through the plugin per OP?

The Wyze Wishlist appears to sort by votes by default, but I’ve not had time to dig through their page to see if they’re using another method.

With the voting plugin installed these are the two available options:

09%20PM

Did I miss a step?

1 лайк

You can add the option like this

<script type="text/discourse-plugin" version="0.8.25">
  api.modifyClass('component:edit-category-settings', {
    availableViews: Ember.computed(function() {
      let views = this._super();
      let voteView = {};
      voteView["name"] = "Votes";
      voteView["value"] = "votes";
      views.push(voteView);
      return views;
    })
  });
</script>

Seems like it would be a nice option to include in the plugin.

5 лайков

Thanks, that gets most of the way.

For some reason items in the extra-nav-item-outlet apply the active class to the list item rather than the link, so ‘Votes’ isn’t shown as active. Is that intentional?

I’ve created a CSS workaround for now, styling both .nav-pills>li.active a and .nav-pills>li a.active.

A post was split to a new topic: Topics that were voted on disappear from user profile after being closed

Здравствуйте, Стивен,

Не могли бы вы помочь объяснить, куда мне нужно поместить код от @awesomerobot, чтобы мои темы ранжировались по голосам на моей странице категории «Boxes with Featured Topics» для рабочего стола?

Большое спасибо,

AGEID

Также хотел бы получить помощь в вопросе размещения этого кода, @awesomerobot?

Я также заметил, что при использовании указанных ниже настроек вкладка «Последние» показывает темы с наибольшим количеством голосов вместо самых свежих, из-за чего нельзя увидеть последние темы вообще. Это баг или я что-то делаю не так?

Хотел бы, чтобы категория по умолчанию сортировалась по количеству голосов (по убыванию), а у пользователей была возможность при желании сортировать по последним. Спасибо.

1 лайк

Нет, это, по-видимому, работает как задумано, хотя это не лучший опыт. Когда параметр «Сортировка списка тем по» меняется на «Голоса», сбивает с толку, что он всё ещё называется «Последние».

Вы можете поместить его в раздел Head вашей темы в админ-панели: администрирование → настройка → темы.

3 лайка