You can close this thread..
Resolved by using app.loadJQueryUI()
I want to write a widget to display all user information
Take a look at the widgets in https://github.com/NodeBB/nodebb-widget-essentials. Those should get you started.
How can I get a user object using this example
Widget.renderOnlineUsersWidget = async function (widget) {
const count = Math.max(1, widget.data.numUsers || 24);
const uids = await user.getUidsFromSet('users:online', 0, count - 1);
let userData = await user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture', 'status']);
userData = userData.filter(user => user.status !== 'offline');
widget.html = await app.renderAsync('widgets/onlineusers', {
online_users: userData,
relative_path: nconf.get('relative_path'),
});
return widget;
};
You want to render the user object from the online users?
The user.getUsersFields
method will retrieve the data you need. You'll then need to modify the template defined in widgets/onlineusers
(or your own alternative).
Please help me with a problem. I need to get an object of an autorized user and give it to the template.
How can I do this in the widget, I've been trying to deal with this problem for 4 days
@julian No, I’m an example of a structure when I need to redo it from nodebb-widget-essentials so that only an autoresized user object is returned to return
@julian Help me pls
The uid of the user that loaded the page is in widget.uid
you can use that to load the user.
Widget.myWidget= async function (widget) {
const userData = await user.getUserData(widget.uid);
widget.html = await app.renderAsync('widgets/myWidget', {
userData: userData,
relative_path: nconf.get('relative_path'),
});
return widget;
};
@baris i love u