Discourse Category Home 🏠

Summary:

Give users each a specific Homepage (“Home Category”) in your community.

It allows you to have a single Discourse in which users have specific “home pages” (read: Category) as determined by their Primary Group.

:link: GitHub: Repository https://github.com/merefield/discourse-category-home
:arrow_right: Install: Follow the plugin installation guide.

Enjoying this plugin? Please :star: it on GitHub ! :pray:

Features

Using only the available interface elements of a normal Discourse, makes this a robust, easy-to-maintain solution.

Configuration

Using normal Discourse functionality:

You are DONE! :tada:

Now whenever someone navigates to your community Homepage, they will be redirected to the Category for which their Primary Group is permissioned.

NB: This follows a simple rule you must stick to: If someone has a Primary Group registered and that is permissioned to a single Category, it will redirect to that Category as their home.

Using a Primary Group in this way has a number of advantages, as you may have noticed from the link above, not least:

  • You can give someone a Title
  • You can give them a Flair
  • You can style their Posts

Other considerations

Make your Category Homepages more impactful by styling them distinctly, with e.g.: Category Banners

Checking distinct Category/Primary Group Permissions

To check your Primary Group is only associated with a single Category, you can use this handy out-of-the-box feature of Discourse, e.g.:

There is but one Category in the list, good! :+1:

The Technical Bit

The exact logic employed is this:

   return CategoryGroup.where(group_id: primary_group).first.category_id

Whilst it might be possible to ‘fudge’ it, it is probably unwise if you use that Primary Group on more than one Category if you expect this to work, so bear that in mind and keep to my recommendation.

Providing more flexibility

I’m open to suggestions on how else to configure this behaviour but I’d like to limit the amount of bespoke settings and use as much out of the box behaviour and data as possible. If you have a simple, elegant solution in mind let me know.

Can’t install plugins/Primary Group thing doesn’t work for you?

If you can’t install Plugins (because you are on a restrictive hosting plan), or find the Primary Group configuration doesn’t work for you, consider this Theme Component alternative: Custom Homepage for Groups which requires more bespoke configuration, but is less invasive.

24 Likes

I get an error message when trying to rebuild after adding this to my app.yml file

Pups::ExecError: cd /var/www/discourse/plugins && git clone GitHub - merefield/discourse-category-home: Alters the user's homepage to become the Category of their Primary Group failed with return #<Process::Status: pid 391 exit 128>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn’

Is it still working for others?

Seems to be building fine. Check your app.yml clone syntax.

I deployed a fix for a missing locale string though :slight_smile: (but that won’t have caused your issue).

1 Like

Yes working great now, thanks for the excellent plugin. Discourse Doctor fixed it, must’ve been a problem in the build last time i rebuilt the app.

1 Like