clarkwinkelmann / flarum-ext-popular-discussion-badge
Adds a popular badge to discussion based on replies or number of views
Package info
github.com/clarkwinkelmann/flarum-ext-popular-discussion-badge
Language:TypeScript
Type:flarum-extension
pkg:composer/clarkwinkelmann/flarum-ext-popular-discussion-badge
Requires
- ext-json: *
- flarum/core: ^2.0
Requires (Dev)
None
Suggests
- fof/discussion-views: For popular conditions based on number of views
- michaelbelgium/flarum-discussion-views: For popular conditions based on number of views, including timeframe
Provides
None
Conflicts
None
Replaces
None
README
Adds a "popular" badge to discussions based on custom criteria.
The extension can be used in two main "modes":
Frontend mode
This mode verifies the badge conditions client-side against the information the current user can see. The database column is not used at all.
In Frontend mode, the following criteria are available:
- Number of comments
- Number of views
The number of views is not computed by this extension.
It requires either michaelbelgium/flarum-discussion-views or fof/discussion-views.
Scheduler mode
This mode makes use of a CRON job to update the discussion status. See Flarum documentation to configure the Scheduler.
You can configure the frequency of the update through the extension settings.
In Scheduler mode, the following criteria are available:
- Number of comments
- Timeframe for the number of comments (in n last hours, leave empty for the total)
- Number of views
- Timeframe for the number of views (in n last hours, leave empty for the total)
The number of views is not computed by this extension.
It requires either michaelbelgium/flarum-discussion-views or fof/discussion-views.
It's only possible to time-constraint the views of michaelbelgium/flarum-discussion-views.
Setting a views timeframe while using the FriendsOfFlarum views extensions will result in an error.
Migrating to new version
If you were using flarumite/simple-discussion-views on Flarum 1.x, you can replace it with fof/discussion-views on Flarum 2.x and everything should continue to work like before.
Notes about the dependency extensions
michaelbelgium/flarum-discussion-views has a higher PHP version requirement than Flarum and this extension (8.4 at the time of writing),
You cannot replace fof/discussion-views or flarumite/simple-discussion-views with michaelbelgium/flarum-discussion-views without some manual steps.
Replacing the extension without purging the database will result in an error about the view_count column already existing.
The FriendsOfFlarum extension does not include a down migration, so the only option is to manually delete the view_count column on the discussions table before enabling the new extension.
You will lose any existing view count when swapping the extensions in that direction.
If you decide to replace michaelbelgium/flarum-discussion-views with fof/discussion-views, it should be possible without purging the database and your view count should be preserved.
Please report any bug directly to those extension's maintainers.
My extension just reads the view count value from those extension, it doesn't touch their database structure.
Installation
composer require clarkwinkelmann/flarum-ext-popular-discussion-badge
Support
This extension is under minimal maintenance.
It was developed for a client and released as open-source for the benefit of the community. I might publish simple bugfixes or compatibility updates for free.
You can contact me to sponsor additional features or updates.
Support is offered on a "best effort" basis through the Flarum community thread.
Sponsors: Daniel Alter, Phenomlab, ctml, GreXXL