| Summary | Allow users to save their favorite filters and optionally define default filters | |
| Preview | Theme Creator |
|
| Repository | GitHub - moin-Jana/favorite-filter: Allow users to save their favorite filters and optionally define default filters | |
| Install Guide | How to install a theme or theme component | |
| New to Discourse Themes? | Beginner’s guide to using Discourse Themes |
Install this theme component
Favorite Filters adds customizable filter shortcuts above the topic filter. Admins can provide default filter buttons, and users can create and customize their own favorite filters.
To save the currently applied filter to your favorites, click the star icon, enter the label, and optionally choose an icon or emoji.
You can also change the order of, delete, and edit your current favorites
Configuration
Custom filters
A theme component cannot create new fields in the database, so to allow users to save their favorite filters, you need to create a custom user field where this information can be stored. Therefore,
- open the user fields configuration. You can find it in the community section of your admin sidebar.
- click “Add user field”.
- choose “Text” as the field type and enter a field name and description.
- leave the field optional.
- enable editing after signup, but don’t show it anywhere.
After you’ve saved the user field, click on the edit button and check the URL. It’ll be something like /admin/config/user-fields/12/edit. The number is the ID of the user field. This is what you enter into the custom user field ID setting of the component. The component will hide the user field from the user’s profile preferences to prevent invalid inputs.
Optionally, you can also restrict creating and saving favorite filters to specific user groups with the custom favorite filters allowed groups setting.
Default filters
The easiest way to configure default filters is to create them as your own filter favorites using the filter UI and insert the value from the user field into the setting. Therefore, you can unhide the user field in the preferences for admin users (show for admin).
Then you can copy the content of the user field into the default favorites setting.
The default filters can also be restricted to certain groups via default favorite filters groups. This is useful, for example, if many filters do not work for unregistered users (because they have no bookmarks or access to certain categories). Similarly, you can configure specific filters as defaults for staff, while regular users can create their own favorite filters without seeing defaults that aren’t relevant to them.



