• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.2 Latest
Buy Hosting

Build a widget and plugin

Scheduled Pinned Locked Moved NodeBB Development
4 Posts 3 Posters 552 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tbaut
    wrote on last edited by
    #1

    Re: NodeBB For a Complete Beginner
    ^ Quite a few years have past since this post, I'm at the same stage than @AccessDenied. I have dev experience, yet I'm lost without any proper explanation around the data flows for NodeBB.

    I want to:

    • Keep records of a mapping between a NodeBB userId and an external user Id extUserID. (using Mongo)
    • Build a Widget that will fetch external data (using this extUserID) and show this custom data for each user.

    I've had a look at many widgets, but I still quite don't get how the data flows from the back to the front-end. e.g to get user data here this widget calls user.getUidsFromSet.

    Now my dumb questions:

    • How do I let the front-end access user data such as this extUserId? Is there a list of those methods somewhere?
    • Can I, and if yes, how can I add this additional property in Mongo to store this extUserId. I get that I can add it manually to mongo but how to let users fill it. This would represent an additional field in the user profile I imagine.
    • From the front-end, how can I alter the DB? There's an api as far as I know but I didn't find info on it.
    • Can you point me to a widget that has similar structure/needs
    1 Reply Last reply
    0
  • oplik0O Offline
    oplik0O Offline
    oplik0 Plugin & Theme Dev Community Rep
    wrote on last edited by oplik0
    #2

    I believe there are two systems for data flow from backend to frontend.

    1. Templates. You can pass data to the renderer as a js object and fill the template with it. Use curly brackets to refer to it.
      Square brackets will give you a translated string.
      For more on templates look here

    2. Websockets. It's not anything unique to NodeBB, so there should be no trouble finding documentation of socket.io
      Have an example of a plug-in using them: frontend and backend

    Both systems work with widgets, so choose the option you prefer. The templates seem better if the data you want to load isn't supposed to change after the page loaded (there is lazy loading if you want to use it though), while with websockets you will have some delay between page load and data getting from backend to frontend, but you can request it dynamically without any reloads.

    Edit: if you just need some more data about an user or something there is also the api - basically you get json data from almost any page you prepend /api/ to. For example community.nodebb.org/api/user/oplik0

    PitaJP 1 Reply Last reply
    1
  • PitaJP Offline
    PitaJP Offline
    PitaJ Global Moderator Plugin & Theme Dev
    replied to oplik0 on last edited by
    #3

    @oplik0 oof those template docs are really outdated. I need to do some work to bring them up to date.

    In the meantime, please refer to the Benchpress docs instead: https://github.com/benchpressjs/benchpressjs/blob/master/docs/readme.md

    1 Reply Last reply
    0
  • T Offline
    T Offline
    Tbaut
    wrote on last edited by
    #4

    Thank you so much for the replies. I'll dig into that again and probably come back with other questions 🙂

    1 Reply Last reply
    0

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development