Topics per category


(Rsnie) #1

Hi, I would like to change the amount of topics per category, I don’t want it per month, but just in total.
How can I change this?

Thanks, Rosanne


(Joffrey Jaffeux) #2

hi @RSnie, I might be wrong but a quick look at the code (discourse/category-list.js.es6 at master · discourse/discourse · GitHub) shows that’s it hardcoded/automatic and I don’t see an easy way to alter this behaviour.


(Sam Saffron) #3

Simplest way to hack this would be to add a theme component with the following in the “header” section:

<script>

(function(){

var CategoryList = require('discourse/models/category-list').default;

CategoryList.reopenClass({
  categoriesFrom(store, result) {
    let categories = this._super(store,result);
    categories.forEach(function(c){
      c.stat = `<span class="value">${c.topics_all_time}</span>`;
      c.statTitle = I18n.t("categories.topic_sentence", { count: c.topics_all_time });
      c.pickAll = true;
    });
    return categories;
  }

});   

})();
 
</script>
  • Admin -> Customize -> Themes
    • New
  • Call it “Totals in category list”
  • Edit CSS/HTML
  • Click common -> Header
  • Add text there
  • Save
  • Add the “Totals in category list” to your current themes and user selectable themes.

(Rsnie) #4

Hi @sam

thank you for the guideline!
I have executed all the steps, only the last step, how I can add it to my current themes, is a step I don’t know how to do…
could you help me again?

PS: when I do “Preview” it looks good.
Thanks!