Category Previews

This component will allow you to add “category previews” to your categories page so users are able to see that a category exists without having access to the actual category. The preview looks like a standard category, but can link to a specified page where a user can be educated on how to gain access.

I’ve included a simple example below, but there are many different ways this component can be configured. Please be sure to read all of the information included in the Theme Settings.

Theme Creator Demo

:warning: You will need to be logged into an account here on Meta for this to work

  1. Navigate to https://theme-creator.discourse.org and log-in using the button in the header if you are not already logged-in

  2. Use the following link to activate the preview of this component: Discourse Theme Creator

  3. Scroll down the category list until you find the “restricted category preview” category and attempt to enter it:

  4. You will be taken to a published page with instructions on how to proceed to access the category:

Settings

I did my best to explain how this component works in the theme settings. The setup is not the most intuitive experience so feel free to ask questions and I will update the instructions to provide clarity.

Additional Notes

I imagine there will be many different edge use-cases. I can’t guarantee that I can make this component work with all of them, but feedback and suggestions are welcome :slight_smile: Here are some things to keep in mind:

  • Currently this will not work with the boxed categories styles. If there are enough requests, I can see about adding support
  • There are above-$CATEGORY classes added to the previews that appear above a specific category. This can be used to add additional styling.
  • This will not work with sub-categories displayed on the categories page
  • Staff users and anonymous users will always see the category previews.
  • Pay special attention to the IMPORTANT notes in the Theme Settings

Installation

:warning: This requires core changes that were added in commit a3e8124 . Please make sure you have updated your site recently enough to have picked it up.

Repository Link
https://github.com/tshenry/discourse-category-previews

If you are unfamiliar with theme components and how to install them, check out the theme installation guide . And if you’d like to learn more about Discourse themes, take a look at this guide .

18 Likes

Oh, I like this, we just implemented special interest groups this week and we’ve had questions on how people would be able to find them. We do use box category styles, so would request that for sure.

4 Likes