Popular Discussion Badge

MIT license Latest Stable Version Total Downloads Donate

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 flarumite/simple-discussion-views.

Scheduler mode

This mode makes use of a CRON job to update the discussion status.
See this thread on how to configure the Flarum scheduler in your crontab

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 flarumite/simple-discussion-views.

It's only possible to time-constraint the views of michaelbelgium/flarum-discussion-views.
Setting a views timeframe while using the Flarumite views extensions will result in an error.

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

Links

4 months later

Released version 0.2.1 with beta 14 support, thanks to the support of @[deleted]

This version will automatically be installed when you update Flarum.

    2 months later

    Very cool, I like the criteria available from the cron mode. Thanks for this.

    Version 0.2.2

    • Beta 15 compatibility
    • Use new Flarum native admin page

    This version will automatically be installed when you update Flarum.

    Update sponsored by @[deleted]

    3 months later

    Version 0.2.3

    • Add compatibility with Flarum beta 16

    I have not actually tested it together with any of the views extensions (I only tested with comment count), but I don't expect anything to break.

    Thanks @ctml for sponsoring the update.

    3 months later

    Would it be possible to add number of likes as a criteria for the selection of popular discussions. I think likes and comments would be interesting in some cases - maybe more then views. Is this something that‘s complicated?

      GreXXL the problem is that discussions cannot be liked, only posts. So the logic to retrieve the likes is a bit more complicated, and the situation where the first post has been hidden or deleted must be handled.

      In a few weeks I'm going to publish an extension that allows up/downvotes on discussions, that might be a better candidate for an integration.

        clarkwinkelmann ah thanks for the explanation - makes sense - didn't think about that! Summing up the likes of all posts of a discussion is also overly complicated 🙂

        The new extension sounds interesting. Will this be a forum-wide thing or something that's a tag-specific option?

          Version 1.0.0

          Adds compatibility with Flarum 1.0+

          Update sponsored by @GreXXL

          GreXXL The new extension sounds interesting. Will this be a forum-wide thing or something that's a tag-specific option?

          I won't spoil everything right now 😇 I will try to make it so you can only do it on some tags. I need it for a suggestions section on a forum I'm working on.

          8 months later

          Version 1.1.0

          • Re-compiled javascript with Webpack 5 to reduce bundle size. Requires Flarum 1.2+
          • Added events for other community extensions to integrate with scheduler mode

          Umutcan the badge is identical to sticky/deleted/approval/subscribed badge in the discussion list and in discussion hero. It uses a red icon with flames but can be customized with CSS.

          There are no other visual changes made by the extension. But the CSS classes and API attributes can be used by custom themes for more advanced styling.

          a year later

          Version 1.1.1

          • Fixed PHP Warning being emitted if conditions setting doesn't exist in database
          • Updated javascript dependencies (did not have any impact on final build file)
          8 months later

          A question about this. Shouldn't this configuration add the popular badge to the discussion?


            GreXXL I guess not? There are not more than 30 views and there likely aren't 3 replies in the last 7 days since it says last reply 9 days ago.

            The time constraint is "until now", not if there's any period of that length in the past where there had been that many comments close to each others.

              clarkwinkelmann ah thanks I did play around too much with it. I didn't notice at first that you can't put a time restraint on the flarumnite views extension. Thanks!