# Sort by Solved/Unsolved Questions in Category

**URL:** https://meta.discourse.org/t/sort-by-solved-unsolved-questions-in-category/65153
**Category:** Feature
**Tags:** solved
**Created:** [6월 27, 2017, 12:27오전 UTC](https://meta.discourse.org/t/sort-by-solved-unsolved-questions-in-category/65153 "2017-06-27T00:27:32Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![Kahi](https://avatars.discourse-cdn.com/v4/letter/k/e47774/32.png) [@Kahi](https://meta.discourse.org/u/Kahi)
#### Post date: [6월 27, 2017, 12:27오전 UTC](https://meta.discourse.org/t/sort-by-solved-unsolved-questions-in-category/65153/1 "2017-06-27T00:27:33Z")

</div>

I wanted to know if there was a way to enable a sort feature for forums that have the solved plugin enabled to sort by Unsolved/Solved questions? The same way that we can sort on a Category by “Latest”, “New”, “Top”, “Unread” by clicking the link at the top.

 ![](https://global.discourse-cdn.com/meta/original/3X/1/9/19594c412192295eb049c22892eda04f5972a15f.png)

I understand that this was [sort of asked before](https://meta.discourse.org/t/can-i-view-a-list-of-solved-and-unsolved-topics-in-a-category/58376), but I’m not sure exactly how to add a new sort “option” that has a link to reorganize the topics by those query params.

---

<div class="post-metadata">

### Author: ![dax](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dax/32/244677_2.png) [@dax](https://meta.discourse.org/u/dax)
#### Post date: [6월 27, 2017, 9:04오전 UTC](https://meta.discourse.org/t/sort-by-solved-unsolved-questions-in-category/65153/2 "2017-06-27T09:04:35Z")

</div>

You can do something like that under Theme \> Common (or Desktop, or Mobile, it’s your choise) \> Body

```plaintext
<script>
  Discourse.ExternalNavItem = Discourse.NavItem.extend({
    href : function() {
      return this.get('href');
    }.property('href')
  });

  I18n.translations.en.js.filters.solved = { title: "Solved", help: "topics with solution" };
  I18n.translations.en.js.filters.unsolved = { title: "Unsolved", help: "topics without solution" };
  
  Discourse.NavItem.reopenClass({
    buildList : function(category, args) {
      var list = this._super(category, args);

      if(!category) {
        list.push(Discourse.ExternalNavItem.create({href: 'http://your-domain-url/?solved=yes', name: 'solved'}));
        list.push(Discourse.ExternalNavItem.create({href: 'http://your-domain-url/?solved=no', name: 'unsolved'}));
        
        
      }
      return list;
    }
  });
</script>

```

In this way you add the buttons Solved and Unsolved on your menu.  
You need only to change the URLs with your domain (and customize with a particular category if you want, eg [http://your-domain-url/c/support?solved=yes](http://your-domain-url/c/support?solved=yes))

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [6월 27, 2017, 9:48오전 UTC](https://meta.discourse.org/t/sort-by-solved-unsolved-questions-in-category/65153/3 "2017-06-27T09:48:32Z")

</div>

> [@Trash](#):
>
> ```plaintext
> if(!category) {
> 
> ```

This will show the solved/unsolved buttons on the main pages, not the category pages.

If you want to add to category pages there’s an example [here](https://meta.discourse.org/t/adding-unsolved-button-to-top-menu-using-custom-html/59758/2) 🙂

---

<div class="post-metadata">

### Author: ![RBoy](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@RBoy](https://meta.discourse.org/u/RBoy)
#### Post date: [7월 12, 2017, 12:51오전 UTC](https://meta.discourse.org/t/sort-by-solved-unsolved-questions-in-category/65153/4 "2017-07-12T00:51:20Z")

</div>

I had the same question but didn’t quite understand how to make it happen. Where do I add this script?  
Would it possible to have a configuration button or setting checkbox to enable sorting by solved?

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [8월 27, 2017, 7:45오전 UTC](https://meta.discourse.org/t/sort-by-solved-unsolved-questions-in-category/65153/5 "2017-08-27T07:45:17Z")

</div>

The `Latest` button remains hightlighted. Is there a way to highlight the `Unsolved` button when this link is entered?

---

<div class="post-metadata">

### Author: ![RBoy](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@RBoy](https://meta.discourse.org/u/RBoy)
#### Post date: [8월 28, 2017, 1:35오후 UTC](https://meta.discourse.org/t/sort-by-solved-unsolved-questions-in-category/65153/6 "2017-08-28T13:35:02Z")

</div>

It would really nice to have a button to sort or show only solved/unsolved posts. I know @david suggested a workaround to add custom HTML but if the plugin did that it would be awesome.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [8월 28, 2017, 1:45오후 UTC](https://meta.discourse.org/t/sort-by-solved-unsolved-questions-in-category/65153/7 "2017-08-28T13:45:19Z")

</div>

Agreed.

I had a **very** brief look at adding it in the form of a theme component, but I think it will need some changes in the plugin itself first.  
I think we need to a Boolean to the category serialiser, as currently there’s no way to know whether a category has “discourse-solved” enabled, its only shipped to the client on a “per-topic” basis.

Definitely achievable though 🙂

---

<div class="post-metadata">

### Author: ![RBoy](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@RBoy](https://meta.discourse.org/u/RBoy)
#### Post date: [12월 3, 2017, 3:53오전 UTC](https://meta.discourse.org/t/sort-by-solved-unsolved-questions-in-category/65153/8 "2017-12-03T03:53:20Z")

</div>

Just checking in on this

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [3월 8, 2019, 3:46오후 UTC](https://meta.discourse.org/t/sort-by-solved-unsolved-questions-in-category/65153/9 "2019-03-08T15:46:54Z")

</div>

> [@schungx](#):
>
> The `Latest` button remains hightlighted. Is there a way to highlight the `Unsolved` button when this link is entered?

This is still an issue - does anyone have any idea how to highlight the Unsolved button?

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [3월 9, 2019, 2:41오전 UTC](https://meta.discourse.org/t/sort-by-solved-unsolved-questions-in-category/65153/10 "2019-03-09T02:41:03Z")

</div>

I don’t think there is a trivial way to do this yet… Maybe somebody can write a plugin or theme component…

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [3월 12, 2019, 1:12오전 UTC](https://meta.discourse.org/t/sort-by-solved-unsolved-questions-in-category/65153/11 "2019-03-12T01:12:33Z")

</div>

@vinothkannans this is just so close to your other theme component, maybe also do one for this … “adds a [all/solved/unsolved] combo to categories with solved enabled?”

In fact, I would just add this to the plugin and have it be a default off site setting.

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [3월 12, 2019, 4:55오후 UTC](https://meta.discourse.org/t/sort-by-solved-unsolved-questions-in-category/65153/13 "2019-03-12T16:55:24Z")

</div>

This does the trick of highlighting the Unsolved button:

```
  api.modifyClass('component:navigation-item', {
    active: Ember.computed("contentFilterMode", "filterMode", function () {
      let contentFilterMode = this.get('content').get('filterMode');
      if (window.location.search && window.location.search.split('&')[0] === "?solved=no") {
        return contentFilterMode === "Unanswered";
      } else {
        return this._super(contentFilterMode, this.get('filterMode'));
      }
    }),
  });

```

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [3월 13, 2019, 7:12오후 UTC](https://meta.discourse.org/t/sort-by-solved-unsolved-questions-in-category/65153/14 "2019-03-13T19:12:34Z")

</div>

It’s done. Added in the plugin itself (disabled by default).

[https://github.com/discourse/discourse-solved/commit/5ddd644e000aaf9e50269a325a79bcac6974cee0](https://github.com/discourse/discourse-solved/commit/5ddd644e000aaf9e50269a325a79bcac6974cee0)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [3월 13, 2019, 8:28오후 UTC](https://meta.discourse.org/t/sort-by-solved-unsolved-questions-in-category/65153/15 "2019-03-13T20:28:28Z")

</div>

Awesome can you document this on the plugin page on meta and close this off.

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [3월 14, 2019, 2:10오후 UTC](https://meta.discourse.org/t/sort-by-solved-unsolved-questions-in-category/65153/16 "2019-03-14T14:10:29Z")

</div>


