Custom Levels

Flarum Custom Levels, levels can be customized, and can trigger events.

Author MIT Latest Version Downloads

⚠ Warning

Attention! Formula has been removed after v3.0.0.

Advantage

  • Comparing to Levels Rank , this extension display the experience bar as the item on the mobile screen,
    which will not cause style issues due to the float floating.
  • Exp is stored on User model, so other extensions can access it. (After v3.0.0)
  • Events of ExpUpdated and LevelUpdated, and notification of LevelUpdated. (After v3.0.0)
  • Support Auto Moderator (After v3.0.0)

Usage

set the display format & reward exp, then run the command php flarum foskym:custom-levels:refresh

image

set the levels

image

you can see the exp logs

image

it's an example

Snipaste_2023-09-28_12-19-05

Installation

Install with composer:

composer require foskym/flarum-custom-levels:"*"

Updating

composer update foskym/flarum-custom-levels:"*"
php flarum migrate
php flarum cache:clear

Links

I took a look at the code and I have a few suggestions 🙂

Maybe the code should be wrapped in a try/catch block so an owner doesn't accidentally crash their forum with an invalid expression? It could become impossible to access the login modal when the eval call throws an error since it's inside a component view method.

It also seems like if the exp expression returns Infinity (division by zero) the code will be stuck in an infinite loop (the while block) and might hang the browser tab.

I also wonder about the performance impact. The way the eval runs in a loop for each possible exp value and this happens on every redraw is probably not optimal for lower-power devices if the exp values are big. The value could be computed only once in oninit and stored on an attribute of the LevelBar component. Or even one step further, make it a computed attribute on the javascript user model, Flarum already has a helper to create such attributes. I think this will never be an issue inside of a discussion because the user profile is within the Post component whose redraws are limited by the SubtreeRetainer already, but when the component is used elsewhere and if another extension causes a lot of unnecessary redraws the performance hits will add up.

    2 months later

    clarkwinkelmann
    Sorry I just saw your suggestions.
    I've tried to solve them before and now the extension has been refactored.
    The version after v3.0.0 is more reliable by storing data in database.

    Updated from 1.2 to 2.0, the simple formula stopped working. I wrote a similar one that raises the level for the number of messages, everything worked. Anyway, thanks for the extension. Should I upgrade to version 3.0 in my case?

      Capybara
      Thanks for using.
      If you only need to display level simply and use formula, please keep it in v2.0.
      If you need other extensions to modify exp and customize the name for each level, please upgrade to the latest version.

      The following extensions are supported in the latest version:

        13 days later

        Updated to the latest version, everything works. Thanks again for the extension. I would like to be able to manually set the value that will be displayed under the avatar. It's like a simple text field

        16 days later

        FoskyM If you only need to display level simply and use formula, please keep it in v2.0.

        hi, how can i install older version?

        5 months later

        I'm running into an issue with the tooltip.
        The settings looks like this:
        https://i.imgur.com/8r7VBRs.png

        And hovering a level looks like this:
        https://i.imgur.com/BFT6DBv.png

          MorrisMoss which version of the extension are you using and have you tried clearing the cache?

          Looking at the source code of the extension on GitHub, it seems like those texts only have a translation in Chinese but not in English. The author might have forgotten to include them in the English translation.