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.

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.: Discourse 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.

15 Likes