Skip to content

Plugin Development

Have a question about building a plugin? Ask here
444 Topics 1.9k Posts
  • plugin latest version not getting updated

    4
    0 Votes
    4 Posts
    2k Views
    julianJ
    The package manager will poll npm for new changes every 10 minutes To answer your question -- yes, the compatibility table is cached, as we don't want to be pulling data from npm in real-time (that would be a tremendous waste of resources and bandwidth for npm!)
  • How is plugin object named

    3
    0 Votes
    3 Posts
    1k Views
    L
    Ah that makes sense thanks
  • [Widget]Realtime topic updates

    4
    0 Votes
    4 Posts
    2k Views
    N
    Anyway, I get all the categories and topics using this route: /api/categories I think there is details on all topics also.
  • How to get all the groups that the user subscribed to?

    2
    0 Votes
    2 Posts
    2k Views
    yariplusY
    On the server, you can do var groups = require.main.require('./src/groups'); groups.getUserGroups([1] /*array of uids*/, function(err, userGroups){ if (err) return; // Returns an array of an array of group data. console.log(userGroups[0]); // Prints an array of groups for uid 1 }); on the client, you can get a list of visible groups by doing: $.getJSON('/api/user/USERSLUG/groups', function (data) { // Returns an object with a 'groups' property, an array of visible group data. console.log(data.groups); });
  • Use Template Files

    3
    0 Votes
    3 Posts
    2k Views
    ShyimS
    Output: 27/3 16:06 [5426] - info: NodeBB is now listening on: 0.0.0.0:4567 27/3 16:06 [5426] - error: TypeError: Cannot read property '@index' of undefined at helpers.displayMenuItem (/root/NodeBB/public/src/modules/helpers.js:13:29) at checkConditionalHelpers (/root/NodeBB/node_modules/templates.js/lib/templates.js:269:76) at parse (/root/NodeBB/node_modules/templates.js/lib/templates.js:424:15) at parseTemplate (/root/NodeBB/node_modules/templates.js/lib/templates.js:133:14) at Object.templates.parse (/root/NodeBB/node_modules/templates.js/lib/templates.js:119:11) at /root/NodeBB/node_modules/templates.js/lib/templates.js:169:30 at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:404:3) TypeError: Cannot read property '@index' of undefined at helpers.displayMenuItem (/root/NodeBB/public/src/modules/helpers.js:13:29) at checkConditionalHelpers (/root/NodeBB/node_modules/templates.js/lib/templates.js:269:76) at parse (/root/NodeBB/node_modules/templates.js/lib/templates.js:424:15) at parseTemplate (/root/NodeBB/node_modules/templates.js/lib/templates.js:133:14) at Object.templates.parse (/root/NodeBB/node_modules/templates.js/lib/templates.js:119:11) at /root/NodeBB/node_modules/templates.js/lib/templates.js:169:30 at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:404:3) 27/3 16:06 [5426] - info: [app] Shutdown (SIGTERM/SIGINT) Initialised. 27/3 16:06 [5426] - info: [app] Database connection closed. 27/3 16:06 [5426] - info: [app] Web server closed to connections. 27/3 16:06 [5426] - info: [app] Shutdown complete. 27/3 16:06 [5460] - info: Time: Sun Mar 27 2016 16:06:43 GMT+0200 (CEST) 27/3 16:06 [5460] - info: Initializing NodeBB v1.0.2 //
  • Adding buttons to posts

    7
    1 Votes
    7 Posts
    3k Views
    OnyxO
    @yariplus I meant a place to chat and get help, not install it as a plugin on my forum Also, I can't find a way to hook into click events on the button. Tried searching through other plugins but I didn't find anything that would demonstrate this. I did see some of the base plugins using action:controller.method syntax but these don't seem to get triggered automatically? Sorry for being a bit of a pain but the docs are a bit scarce, and while I'm OK with JavaScript in general my NodeJS knowledge is... lacking, at best, so poking around the source is not something that's very effective in my case.
  • Can you follow yourself?

    6
    0 Votes
    6 Posts
    3k Views
    A
    @julian said: (provided you're in the right room) that's actually what got me to thinking i could do this. See my bot doesn't actually ever enter a room and in my testing seems to get new post events sent to it for all posts except my own. so if i could figure out a way to get my own as well that would be a simple matter of looking for new posts by my user id and processing them for the "gifmoji" tags. i suppose i could do it as a "gifmoji mod" so i run the module on a different login, but that means that i'd need the cooperation of the forum staff and i'd probably also have to be a mod (because i'd know the bot's credentials and it would be a mod) and that is very much :do_not_want.avi: still, i'll figure something out.
  • 0 Votes
    4 Posts
    3k Views
    barisB
    No they return the score of the value. db.sortedSetScore(set, data.name, function(err, score) { console.log(score); });
  • 0 Votes
    7 Posts
    3k Views
    frissdiegurkeF
    Calculations/Evaluations are not part of the lightweight template engine NodeBB uses. (AFAIK) I guess the best would be to intercept the filter:post.getPosts hook and add your custom index values...
  • 0 Votes
    1 Posts
    1k Views
    D
    I need to show some text but this texts is saved with a label that increase: for example var save={'0':'first text','1':'second text'}; now I need to show this text in my tpl page so in my controllers I pass this vector to page. My problem is: how can I read the value in the vector with begin and with end??is it possible or not? <!-- BEGIN posts --> <!-- END posts --> and I try to use in the IF some regex expression?
  • 0 Votes
    1 Posts
    4k Views
    D
    In my library.js I need to create a custom route so I do: params.router.get('/admin/test/:nameTest', params.middleware.admin.buildHeader, controllers.renderTest); But I obtain "Error executing 'static:app.load' in plugin 'nodebb-plugin----". Anyone can help me to resolve this problem?
  • An idea of new plugin html-preparser

    18
    2 Votes
    18 Posts
    7k Views
    Q
    So now, I have questions to the NodeBB development team. @julian About @frissdiegurke 's idea. What do you think? Is it secure or do you have any better ideas, policies , plans? To manage dependencies between plugin, Can we enforce to install and activate plugins by dependencies? Or can we give warnings of wrong configurations, dependencies and so on by plugin on admin UI ( dash board? )? Do we have secure way to add/remove/modify custom data by plugin in a filtering pipe? For example, on filtering hook, data.pluginData.<plugin name> can be always for plugins (means some sure for core will not use it for different reason!! ), whether they are removed or not after filtering. I know if I select good name( random or highly uniq), then it will be quite safe but it will be better if we have an official space. If I want to make a npm module which is dedicated to NodeBB while it's not a plugin, then what is good name for. Maybe nodebb-helper-any-name. It may be for individual plugins. I had one more, but I forgot what was it while writing....
  • How to check if a visitor is registered or a guest?

    Solved
    13
    0 Votes
    13 Posts
    4k Views
    yariplusY
    I'm not sure why that appears on the docs. That change has not been added into the code yet. https://github.com/NodeBB/NodeBB/pull/4162
  • How can i get the content of a topic?

    Solved
    2
    0 Votes
    2 Posts
    1k Views
    N
    @Nisthar I was not able to get the content of a post by using the hook "filter:topic.get" But i used "filter:parse.post" to do it
  • Get actual request inside a plugin hook

    6
    0 Votes
    6 Posts
    2k Views
    julianJ
    @Filozofer while the issue in discussion by @bentael and @baris is good, keep in mind it is still in development and can change at a moments notice!
  • What do you mean like "moderator"?

    9
    1 Votes
    9 Posts
    5k Views
    B
    @pichalite hadnt noticed it... dang it lol i was thinking about group mods.
  • Some ideas and on going development of new plugin called MagicBlock

    20
    4 Votes
    20 Posts
    9k Views
    Jared14406J
    @qgp9 lol I need 3 upvoted it's good to have upvotes it gives u reputation!!!!
  • Store data about users at the plugin level

    2
    0 Votes
    2 Posts
    1k Views
    yariplusY
    What I do sometimes is create a new db entry, with the key prefixed by the user object key. The core never knows it exists, so it should always be forward compatible. db.set('user:' + uid + ':something', "somevalue"); db.setObject('user:' + uid + ':someobject', {one: "thingone", two: "thingtwo"}); You just have to make sure to delete it if the user is deleted, so there's not an orphan key left behind. db.delete('user:' + uid + ':something');
  • How get ID of a plugin

    3
    0 Votes
    3 Posts
    2k Views
    barisB
    You can use Plugins.isActive method.
  • how specify in router any value

    3
    0 Votes
    3 Posts
    2k Views
    barisB
    Do this router.get('/user/:username', controllers.red); controllers.red = function(req, res, next) { console.log(req.params.username); }