Skip to main content

Leaderboard widget

The Leaderboard Widget renders a specified leaderboard on the page and can be configured to display results for different time periods (day, week, month or all-time).

Leaderboard widget showing user rankings The Leaderboard Widget displaying user rankings with points and positions

Implementation

To render the Leaderboard Widget, add a call to the Mambo leaderboard() function in the mamboCallbacks() array. The example below shows all available options. Note that the only required option is leaderboardId, so you could simply use: Mambo('.selector').leaderboard({leaderboardId: <id>}).

JavaScript

Configuration options

Each option is explained in detail below. Note that only the leaderboardId option is required.

Basic configuration

OptionDescriptionDefault ValueSample Value
leaderboardIdSpecifies which leaderboard to display. If not provided, the widget will display a message asking to select a leaderboard. The leaderboardId can be found in the administration panel.N/A8ds8a98asd787a
titleOverrides the default title of the widget.N/AMy Ranking
heightSets the height of the leaderboard element in pixels.500400

Display options

OptionDescriptionDefault ValueSample Value
withMenuDetermines whether to display a navigation menu showing all available leaderboards.truefalse
picClassOverrides the default icon used when broken profile images are identified.mambo-sprite mambo-silhouette-lgmy-picture-icon
useUnitsDetermines whether to show units of measure for points being tracked by the leaderboard. Only applies to leaderboards based on a single point type.falsetrue

Time period and pagination

OptionDescriptionDefault ValueSample Value
periodDetermines the time frame for retrieving leaderboard data. Accepted values: day (today's leaderboard), week (current week), month (current month), and all (overall leaderboard).allmonth
pageSpecifies which page of leaderboard users to retrieve (zero-indexed).01
countSpecifies the number of leaderboard users to retrieve per page.1020
myRankCountSpecifies how many users to show above and below the current user. For example, a value of 10 will display the top 10 users, the current user, and the bottom 10 users.1020

Points information

OptionDescriptionDefault ValueSample Value
hasEarnPointsDetermines whether the "How do I earn Points?" link is displayed. Recommended to leave enabled.truefalse
earnPointsUrlProvides an alternative behaviour for the "How do I earn Points?" link. By default, this opens a popup with available behaviours. If set, the link will open the specified URL instead.N/Ahttp://mydomain.com/profile/user

Tab options

OptionDescriptionDefault ValueSample Value
tabs.selectedDetermines which tab will be open when the widget first loads. Valid values: top_10 or my_rank.my_ranktop_10
tabs.showDetermines whether the widget's tabs should be displayed.falsetrue

Tag filtering

OptionDescriptionDefault ValueSample Value
tagFilters the leaderboard by a single tag. The tag must be added to the "filterable by tag" field of the Leaderboard in the Administration Panel. Note: Leaderboards only support single tag filtering.N/A'tagA'
useTagForAllApplies the same tag filter to all leaderboards found in the menu.falsetrue