Skip to content

Plugin Development

Have a question about building a plugin? Ask here
444 Topics 1.9k Posts
  • Ask for Suggestions: Add topic fields, visualize them

    Solved
    4
    0 Votes
    4 Posts
    2k Views
    G
    @PitaJ I think I found a way, I use client-side on 'action:ajaxify.end': components.get('topic').append(html) where html is the parsed (by jQuery) element I want to show. If there is a way to do that server side instead of client side, I would really appreciate if you let me know And also I don't really get how can I understand what every hook method takes as parameters, when I click on one of them in the hooks list on GitHub, it just show me a line of code, and I don't get what that line means (for example in filters:parse.post goes where there is an if statement, what that means?)
  • Plugin works in development but not in production

    Solved
    13
    1 Votes
    13 Posts
    5k Views
    deiden26D
    @baris Thanks! You and the rest of the NodeBB team / community rock.
  • Redirection to external url

    4
    0 Votes
    4 Posts
    2k Views
    barisB
    Yeah forgot to mention you can put that piece of code in your custom header at /admin/appearance/customise#custom-header
  • bug? "double" pathing on jquery-ui css images

    2
    0 Votes
    2 Posts
    2k Views
    Bruce LeeB
    I solved the issue using other widget instead of jquery-ui.
  • Best way of forking a plugin?

    Unsolved
    2
    0 Votes
    2 Posts
    1k Views
    julianJ
    Hey there! Thanks for investigating a fix You can fork the plugin on the GitHub pages, and when you are ready you can submit a pull request to merge those changes back into the upstream repository. Then your work can be shared to everybody!
  • This topic is deleted!

    1
    0 Votes
    1 Posts
    8 Views
  • How do I add a button on the profile's portrait?

    2
    0 Votes
    2 Posts
    2k Views
    P
    @Thadeusz-Lay don't think there are hooks to do that. You can accomplish it by adding some js and css in ACP -> Appearance -> Custom HTML & CSS. Here is an example. You will need to add code to handle what needs to happen on clicking the button. Custom Header: <script type="text/javascript"> $(document).ready(function() { $(window).on('action:ajaxify.end', function(ev, data) { $('[component="account/cover"] .avatar-wrapper').append('<button class="btn-new"><i class="fa fa-plus"></i></button>'); }); }); </script> Custom CSS: .avatar-wrapper .btn-new { height: 2em; width: 2em; line-height: 2em; border-radius: 50%; border: none; background: #F44336; color: #fff; overflow: hidden; top: 93px; left: 4px; position: absolute; }
  • Using socket.io's "namespace" feature

    1
    0 Votes
    1 Posts
    1k Views
    Z
    Hi, I would like to use NodeBB/src/socket.io as much as I can for my own application, but I would like to separate all of my own socketing into a custom namespace (not just method name namespace, but Socket.IO's own namespace feature.) To get a server object that listens on a namespace I do var socketio = require.main.require('./src/socket.io'); var nsp_server = socketio.server.of('/custom_namespace'); Now my issue is, if using nsp_server to listen to connections, such as here: nsp_server.on('connect', function (socket) { console.log(socket.uid); } The socket object does not seem to come already processed by the middleware that the proper NodeBB sockets do (such as the authorize() in src/socket.io/index.js which is what populates the socket.uid value) On the other hand, if I am to use src/socket.io/plugins.js, then I won't have to deal with the nsp_server.on('connect', etc... But in that case, I won't be able to use the custom namespace feature (right?) So, either, how do I (re)use NodeBB socket middleware without (re)writing it in my own code, or how do I use SocketPlugins with a custom namespace? Thanks for reading. I would greatly appreciate any input! lets discuss!
  • How use nodebb-plugin-emoji-static?

    6
    0 Votes
    6 Posts
    3k Views
    frissdiegurkeF
    If configured correctly, it adds custom image files as emoji.
  • howto get the new content of edited post?

    Solved
    5
    0 Votes
    5 Posts
    2k Views
    Bruce LeeB
    @baris works perfectly.
  • Nodebb Widget and Define()

    3
    0 Votes
    3 Posts
    2k Views
    N
    Thank you! I am a super noob to require JS and I had a feeling it was something related to calling a require but just am still trying to get used to the frameworks in play
  • How to access settings values in "quickstart" plugin

    2
    0 Votes
    2 Posts
    2k Views
    PitaJP
    @Thadeusz-Lay so are you trying to create your own plugin? meta is a NodeBB module. You have to require it from NodeBB with require.main.require('./src/meta') on the server side.
  • JQuery in Widget Template

    Solved
    3
    0 Votes
    3 Posts
    2k Views
    N
    You can close this thread.. Resolved by using app.loadJQueryUI()
  • How create a new way to order post

    3
    0 Votes
    3 Posts
    2k Views
    D
    @pichalite thank to your suggest it works I have only topics that aren't "Pin". If I do this: [image: yQkAvDi.png] The topics show in this way: [image: D2sMlCG.png] In the image I can see that "primo creato " topic that I have PIN it's the last but I want to become the first. I want that when I PIN a topic, this must be the first among the topics (now it is the last). In plugin.json I put this hook: { "hook": "filter:category.topics.prepare", "method": "ordina_zero" } and in library I do this: converter.ordina_zero = function(data, callback) { //Prendo quale element del sorted ha cliccato user.getSettings(data['uid'], function(err, settings) { if (settings.categoryTopicSort === 'zero') { data.reverse = false; data.set = 'cid:' + data.cid + ':tids:posts'; } callback(null, data); }); }; My purpose is show the PIN topic at the beginning and after show the topics with their order. Can you help me?
  • Retrieve select info of all users in database.

    3
    0 Votes
    3 Posts
    2k Views
    yariplusY
    For anyone looking to do this for a plugin, it's easy enough using getObjectValues() var db = require.main.require('./src/database') var User = require.main.require('./src/user') db.getObjectValues('steamid:uid', function (err, uids) { if (err) return console.log(err) uids = uids.sort().filter(function(item, pos, ary) { return !pos || item != ary[pos - 1] }) User.getUsersFields(uids, ['username', 'email', 'steamid', 'profileurl'], function (err, users) { if (err) return console.log(err) users.forEach(function (user) { // Do a thing here. console.dir(user) }) }) })
  • How specify dependency in my plugin

    3
    0 Votes
    3 Posts
    2k Views
    BriB
    Alternatively, just install it with the --save flag and it will pin the current version in your package.json npm install --save sparkpost
  • This topic is deleted!

    3
    0 Votes
    3 Posts
    18 Views
  • How can I disable a plugin

    2
    0 Votes
    2 Posts
    2k Views
    yariplusY
    Call toggle active then restart or reload nodebb. var Plugins = require.main.require('./src/plugins'); var Meta = require.main.require('./src/meta'); var pluginid = 'nodebb-plugin-yourplugin'; Plugins.isActive(pluginid, function (err, isActive) { if (err) return console.log(err); if (isActive) Plugins.toggleActive(pluginid, Meta.restart); // or Meta.reload })
  • Get user info in post route registered in plugin

    3
    0 Votes
    3 Posts
    2k Views
    I
    Thanks @jarey , I was using shiny new fetch api but wasn't including credentials. silly me.
  • 0 Votes
    9 Posts
    4k Views
    yariplusY
    Happy to help!