Skip to main content

Leaderboards template

Description

This template is used by the Leaderboard Widget to display users in a particular leaderboard.

Control classes

ClassDescriptionRequired
mambo-ctrl-earnDisplays the "How do I earn points?" popup when clickedNo
mambo-ctrl-periodChanges the leaderboard's time period when clicked. All period elements must be within the same parent and use this class. The order of elements is important (Overall, Day, Week, Month)No
mambo-ctrl-menuDisplays the leaderboard selection menu in the element identified by mambo-ctrl-menu-displayNo
mambo-ctrl-menu-displayContainer element for the list of available leaderboardsNo
mambo-ctrl-menu-itemChanges the leaderboard to the selected one when clickedNo
mambo-ctrl-scrollEnables scrolling for the user list. Must have explicit height set and be contained within a mambo-ctrl-leader elementNo
mambo-ctrl-leaderContainer element for the mambo-ctrl-scroll elementNo
mambo-ctrl-tabSwitches between Top 10 and My Rank views. First tab loads Top 10 plus current user, second tab shows leaderboard with current user in the centreNo
mambo-ctrl-selectedIndicates the current user's element. Used with mambo-ctrl-scroll to keep the selected user in view while scrollingNo

Template data

VariableDescriptionType
lbDataObject containing leaderboard settings. See Leaderboards API documentation for detailsObject
dataArray of top users in the leaderboardArray
isLoadingFlag indicating whether leaderboard data is still loadingBoolean
periodCurrent time period for which leaderboard data is being retrievedString
myRankTrue if displaying My Rank tab, false if displaying Top 10 tabString
tabsLeaderboard configuration data for tabsObject
heightHeight of the widgetInteger
titleTitle to display for the current leaderboardString

Implementation example

This example shows a basic leaderboards template with period selection and menu:

JavaScript

Customisation options

Consider these enhancements:

  • Adding user avatars and profile pictures
  • Displaying point values and rank changes
  • Implementing animations for rank changes
  • Creating responsive designs for different screen sizes
  • Adding visual highlights for the current user
  • Implementing search functionality for finding specific users