/users page works properly as a leaderboard. I was willing to add it on top menu.
Is there a easy way to do it? Maybe without code ![]()
In a discussion titled “How to add /users on Top Menu?” under the Dev category, users explore ways to add the /users page (a leaderboard) to the top navigation menu without coding. joebuhlig provides a JavaScript snippet to add it via Customize > Theme > </head>, which works but exposes user activity data to all users — a concern raised by BobbyZopfan. sam notes that maintaining the nav across the directory is complex, and while tophee suggests extending the top menu site setting to handle arbitrary URLs, sam clarifies that such a change would be very complex — though adding /users to the top nav is now achievable via a theme component (see meta.discourse.org/t/add-users-to-top-nav/63681). BobbyZopfan also reports a bug: after removing the script, navigating to /u manually or refreshing results in a blank page, despite the “Users List” button working correctly from the map page — highlighting inconsistent routing or state handling.
/users page works properly as a leaderboard. I was willing to add it on top menu.
Is there a easy way to do it? Maybe without code ![]()
Try this in Customize - Theme - </head>
<script>
Discourse.ExternalNavItem = Discourse.NavItem.extend({
href : function() {
return this.get('href');
}.property('href')
});
I18n.translations.en.js.filters.users = { title: "Users", help: "User leaderboard" };
Discourse.NavItem.reopenClass({
buildList : function(category, args) {
var list = this._super(category, args);
list.push(Discourse.ExternalNavItem.create({href: '/users', name: 'users'}));
return list;
}
});
</script>
This is sort of there, the big challenge is keeping that nav around when you hit directory, far trickier problem.
Would it be a big deal to extend the functionality of the top menu site setting so that it can handle any url path (based on the site url) in a similar fashion as it now handles category/<category_name>?
This is now doable in a theme component.
At the moment, yes, it would be a very complex change.
Your script is very very useful, in that we can see, in one screenful, the list of all the likes received, given, topics read/written, replies given/viewed, visits to the site. And also all the users are shown very neatly on the map (maps location plugin is installed on my instance). But sorry to find that this whole useful information also becomes available to all users, which is undesired.
Alternatively, if we delete this script and go to Admin> Settings> Users, then much info, likes given/received, visits made etc are not shown.
So, is there a way to disable this view to normal users?
2, As an experiment, I deleted this script, because of this undesired trait, I found that I can still go to that URL, which was there when script was working (link), and found the user map.
Now the question/curiosity is that, while on this page, if I click on ‘Users List’, the button works fine and shows the list of users and their activity as desired (in the URL bar, url now shows as: https://bathinda.xyz/u ).
But if I refresh this page or later on manually type this url and go to /u page, then nothing is shown and a blank page keeps showing.
What makes it do so?