Advice needed for tailoring Discourse to my organisation

As @hawk pointed out, Discourse is not really optimized to have hundreds of categories. One aspect of the performance issue is that the Discourse site model loads every category when it is created (see here). So even if you achieve your desired functionality, you may find that your 250+ category instance starts slowing down and you’ll either need to modify your environment, or modify various aspects of Discourse’s server and client logic to load categories more selectively (or both).

However, with the performance issue firmly in mind, the functionality / UX you’re proposing is possible. I have done something similar to this in an ‘unreleased’ plugin (It’s here). It won’t work for you out of the box though, and it does a whole bunch of other things you don’t need. I can provide some ad hoc advice and assistance to whoever works on your version of this, but I’m not available for hire or to focus on a project like this.

If someone attempts this, what you need is:

  • User custom fields storing the region and branch category ids (cast them as integers).

  • A new /user route that allows the user to change their region and or branch (explainer text + category drop downs). e.g.

    There is a user-main-nav plugin outlet for the button and you’ll need to add a new user route.

  • A migration or some other auth logic to set the user’s initial region and branch.

  • Discovery route redirects to the region / branch categories. Probably just on the / and /categories routes, which still allows the user to visit other categories, but will direct the user to their branch / region in most instances, e.g. when they click the logo in the top left. Something like:

     DiscoveryRoute.reopen({
       redirect() {
         const user = Discourse.User.current();
         const path = window.location.pathname;
         if (path === "/" || path === "/categories") {
           DiscourseURL.routeTo('c/' + user.branch_id);
         }
       }
     });
    

There are a few ancillary issues that you’ll face, for instance:

  • Do you want to place restrictions on when / how often a user can change their region / branch? (my implementation of this is here).

  • Do you want branch or region specific moderators? I created a separate plugin for this actually: Moderator Extension

Probably others that I’m forgetting atm.

The bottom line is that the functionality / UX you’re proposing is doable, but the performance risk is not insignificant.

6 Likes