Skip to content

Plugin Development

Have a question about building a plugin? Ask here
437 Topics 1.9k Posts
  • Topic create and update via API and event sequencing

    2
    0 Votes
    2 Posts
    28 Views
    barisB
    A socket event is sent when a new topic or reply is made, they are called event:new_topic and event:new_post. We listen to that and update the ui when a new reply comes in.
  • How to rewrite post reply feature ?

    1
    0 Votes
    1 Posts
    360 Views
    Xuân VinhX
    Hi there, I have a plugin for post replies feature I have a few questions Take out the main post How to query only parent posts (it has no parents) How to get list of child posts of a parent post (how to use api in plugin) In short, I want to create post replies similar to Facebook comments Thanks for any help
  • Advanced Search Widget

    3
    0 Votes
    3 Posts
    459 Views
    L
    @יושב-אוהלים Hi, I would appreciate it if you could write how it can be done
  • Customization of Bootbox

    2
    0 Votes
    2 Posts
    69 Views
    barisB
    Depending on what you want to change, you can modify it via css or override the bootbox.dialog method like we do in core https://github.com/NodeBB/NodeBB/blob/master/public/vendor/bootbox/wrapper.js#L27-L45
  • Plugin created and activated. However, it doesn't show on admin panel.

    2
    0 Votes
    2 Posts
    58 Views
    barisB
    Try navigating to the route created by the plugin for the admin page, it should be something like /admin/plugins/pluginname. If that is giving a 404 that means your plugin isn't being loaded properly on startup. Check nodebb logs for any errors / warnings. The quick start plugin creates a route at /admin/plugins/quickstart https://github.com/NodeBB/nodebb-plugin-quickstart/blob/master/library.js#L37
  • Override/Extend Client-Side Core Search Module

    Solved
    6
    0 Votes
    6 Posts
    267 Views
    W
    @baris Just found the root cause of the weird behaviour! Turns out that there is a bug in my NodeBB dev startup scripts. One of the steps involves automatically symlink plugin packages for a more seamless plugin development. The issue happens when the yarn link only happens after NodeBB build but before NodeBB start Thus there is this weird behaviour of the plugin is loaded but its public assets are not built 🫠 Thank you for your pointers and help
  • What and Why this error

    12
    0 Votes
    12 Posts
    201 Views
    traarrrT
    After a lot tries here and there I have reached the cause of this issue... I cause is some plugins which are not running properly. It is due to this it hinders the compilation of client side JS for all the plugin which loads after that.
  • Clustered NodeBB and plugin socket methods

    7
    0 Votes
    7 Posts
    204 Views
    barisB
    Yeah your flow should work, we don't trigger it on all instances as that would cause issues if the function is doing db writes for example. You would have 2+ instances trying to create the same records etc.
  • Page/route changes

    4
    0 Votes
    4 Posts
    93 Views
    R
    My fault. I wasn't calling ajaxify.go correctly. All works now.
  • Query all the objects by key.

    4
    0 Votes
    4 Posts
    158 Views
    barisB
    I would advise against using those since they operate on fields that are not indexed. If all you want to store is a uid and score pair you can use sorted sets like below. //setting values await db.sortedSetAdd('pluginname:users:customstats', [score1, score2], [uid1, uid2]); // getting first 10 values await db.getSortedSetRevRange('pluginname:users:customstats', 0, 9);
  • A section of my template is not loading (unless I refresh the page).

    3
    1 Votes
    3 Posts
    98 Views
    enbermudasE
    I don't know why, but taking those conditionals checks that I have to the route controller fixed the problem. I don't need to reload the page anymore.
  • Displaying a text box whenever an admin decides to delete an user's topic

    1
    0 Votes
    1 Posts
    82 Views
    traarrrT
    Hi all, Well this is my first time writing a plugin which involves using client side hooks... For a start, i would want my plugin to listen to a hook which activates when the topic page is completely loaded and topic tools are loaded too. For which I wrote this function: 'use strict'; /* globals document, $ */ $(document).ready(function () { function alertType(type, message) { require(['alerts'], function (alerts) { alerts[type](message); }); } console.log('nodebb-plugin-quickstart: loaded'); $(window).on('action:topic.loaded', notifyBox); function notifyBox() { console.log("in notify box"); alertType('success', "done") } }); but this is not working... I can only see "nodebb-plugin-quickstart: loaded" on the console. Where am i going wrong here??
  • How to write plugin in typescript?

    1
    1 Votes
    1 Posts
    85 Views
    starkorebaS
    Hello, first of' thanks for the amazing work ! For the context: I'm a junior developer from France, so excuse my english (and my limited understanding of everything lol). I was looking for a software alternative to build a forum RPG. I just installed NodeBB on Ubuntu 20 (Focal) working on WSL 2. I'm using redis and want to write plugin using typescript. It would be great to have a guide version of the Quickstart plugin in typescript ! I know its possible to write plugin in typescript, the emoji plugin does that. But it would save me so much time to have a guide that explain the extra step we need to do in order of compiler and make it work on NodeBB. Here's my questions tho: Is it in the roadmap team of NodeBB to document how to write plugin in typescript? Did the team plan to write a typescript version of NodeBB? Although it would be great to have some more advanced example right in the documentation on how to do something and what are the step to make it work. Like here : https://community.nodebb.org/topic/16994/how-do-i-add-custom-user-fields-to-my-theme Like "if I want to add/ change something, I have to think of the scope of this features and what's need to be modify in other file to be working properly". Or at least, say it in the documentation a little bit more straightforward. So that beginner will understand that first sight. But I think examples are more worthy than tons of words. Is it possible for beginner to contribute on the documentation to make it more specific and understandable for beginners, or is it a documentation for more experienced developers and a choice of the team (and don't want to change that)? Is it because from a plugin to another, things might be working so differently that it's not worthy to do a more detailed documentation ? Because people might be wanted to write plugin over time, mutualisation of knowledge would be great, so that might simplified the process of each developer trying to write plugin have to go throw investigations to understand how NodeBB works before even start to develop the actual plugin. For example: How to interact with the database explain in this answer: https://community.nodebb.org/topic/17657/best-way-to-store-plugin-data-in-database-in-context-of-compatibility/2?_=1714543873650 for me this should be in the documentation. In conclusion, I feel like in general people agree that it's difficult to start writting plugin without investigate and dive in the structure file of the source code. I'm willing to help on that make it easier to really understand how NodeBB works for developer. So that anyone not familiar with the source code can start almost immediately customization.
  • This topic is deleted!

    2
    0 Votes
    2 Posts
    29 Views
  • Custom helper function for benchpress

    2
    0 Votes
    2 Posts
    122 Views
    barisB
    https://community.nodebb.org/post/88242 I think this answers your question. Let me know if it doesn't work.
  • Create custom fields in composer

    4
    0 Votes
    4 Posts
    428 Views
    K
    Hi @Ali-Hussain , Did you ever figure this out? I am trying to do something similar by adding a custom field to the post object based on a button I've added to the composer.
  • Is there a way to extend database read/writes without modifying the original code?

    Solved
    2
    1 Votes
    2 Posts
    334 Views
    barisB
    You can modify/override methods on the db object but not sure if it's worth the trouble.
  • Clean way to provide alias for link

    5
    0 Votes
    5 Posts
    197 Views
    Johan WathermanJ
    Ok, looks like I know what I need to know, what's possible, what doesn't make sense, and what could be a workaround. Thank you very much.
  • Some question about upload image

    2
    0 Votes
    2 Posts
    154 Views
    barisB
    filter:uploadImage hook receives some params that you can use to differentiate between a profile/cover picture for a user vs an image that is uploaded to a post. When a cover or profile image is uploaded the folder passed to the hook is set to profile. Also the image object will have a name field that is set to either profileAvatar or profileCover depending on what is being uploaded. When you upload a image to a post the folder is set to files. I think the upload from url is no longer used since that is handled client side now when someone tries to set their profile image from a url. In the past we used to download the image from that url server side but not it is handled client side with the cropper lib.
  • Best way to store plugin data in database in context of compatibility

    2
    0 Votes
    2 Posts
    247 Views
    barisB
    Do I understand correctly that I should simply save the collection of X objects like any other data in NodeBB, using its abstract data access mechanisms? Yes, just use the db.setObject and other methods available, this ensures your plugin works on redis/psql/mongodb. Can I expand the user data, topic, posts, etc. with an additional field in the database (probably containing the id of related X objects so that I can immediately ask about the right objects)? Yes, some plugins like QnA do this and add solved/isQuestion fields into the topic objects. NodeBB is very flexible in terms of data structure.