Sort/filter by likes


(cz) #1

is there any way to sort topics or posts by number of likes?

after you click “TOP”, you have a page to list topics sorted by replies/views/activity

can we search/filter/sort topics/posts by likes?


(cpradio) #2

You can using the query string.

See the order section


(Philippe Rollin) #3

Sorry for the noob question here but where to append such query string so a top menu item can take advantage of it (like the “features” or “bugs” top menu links on this forum).
Do I have to create some custom html for this?


(Sam Saffron) #4

Its a site customization:

admin -> customize -> css/html -> </body>

<script>
  Discourse.SiteSettings.top_menu = 'latest|new|unread|bookmarks';
  
  Discourse.ExternalNavItem = Discourse.NavItem.extend({
    href : function() {
      return this.get('href');
    }.property('href')
  });

  I18n.translations.en.js.filters.bugs = { title: "Bugs", help: "Open Bugs" };
  I18n.translations.en.js.filters.features = { title: "Features", help: "Open Feature Requests" }

  Discourse.NavItem.reopenClass({
    buildList : function(category, args) {
      var list = this._super(category, args);
      if(!category) {
        list.push(Discourse.ExternalNavItem.create({href: '/category/bug?order=op_likes&status=open', name: 'bugs'}));
        list.push(Discourse.ExternalNavItem.create({href: '/category/feature?order=op_likes&status=open', name: 'features'}));
      }
      return list;
    }
  });

 </script>

[ARCHIVE] Topic List Previews
(Alessio Fattorini) #5

Great!! :+1: just used on my Discourse!


(Sam Saffron) #6