Problem with widget plugin

NodeBB Plugins
  • #1

    I have made a widget plugin for my website, and it shows in the plugin list but the widget does not get added to the widget list. Here is the code:


        "id": "test",
        "name": "Test",
        "description": "Test plugin.",
        "url": "",
        "library": "./lib/plugin.js",
        "hooks": [
    			"hook": "filter:widgets.getWidgets", "method": "defineWidgets", "callbacked": true
    			"hook": "filter:server.create_routes", "method": "addRoutes", "callbacked": true
    			"hook": "filter:widget.render:status", "method": "renderStatusWidget", "callbacked": true


    function(module) {
    	    "use strict";
    	    var Widget = {
    		    templates: {}
    	    Widget.renderStatusWidget = function(widget, callback) {
    		var html = Widget.templates["status.tpl"];
    		callback(null, html);
    	Widget.defineWidgets = function(widgets, callback) {
    		widgets = widgets.concat([
    				widget: "status",
    				name: "Server Status",
    				description: "Minecraft Server Status.",
    				content: Widget.templates["admin/status.tpl"]
    		callback(null, widgets);
    	Widget.addRoutes = function(custom_routes, callback) {
    		var templatesToLoad = [
    			"status.tpl", "admin/status.tpl"
    		function loadTemplate(template, next) {
    			fs.readFile(path.resolve(__dirname, './templates/' + template), function (err, data) {
    				Widget.templates[template] = data.toString();
    		async.each(templatesToLoad, loadTemplate, function(err) {
    			if (err) {
    				throw new Error("Error loading templates: "  + err);
    			callback(err, custom_routes);
    	module.exports = Widget;

    (code tags are all messed up, so excuse me for the half-formatted code)
    (this code is taken from nodebb-widget-essentials and edited)

  • #2

    Just verifying that you activated the plugin and then restarted NodeBB?

  • #3

    @psychobunny Yup, activated plugin in admin panel and hit the Restart NodeBB button. (also tried forever restart)

  • #4

    I see a couple of syntax errors in your code, can you try this please?

    1. you're missing an opening bracket before function right at the top (although maybe you copy paste error)
    2. you forgot to define async, fs, and path but you use that to pull the templates 馃檪
  • #6

    You should be getting error messages when you run it with node app.js, at least I was getting these errors at first when I tried running your code

    My guess is maybe your template files aren't uploaded or you're pointing to the wrong path?

  • #7

    @psychobunny I was running the version without the opening bracket with node app.js and didn't get any errors, so I guess it's not printing errors or something.

  • #8

    Maybe you're running on production? or maybe the error only happens when you attempt to activate the plugin. I got this just from running node app and trying to activate the plugin

  • #9

    @psychobunny Ah, did ./nodebb dev, and look what popped up:
    warn: [plugins] Plugin 'mcpartyzone' not found
    How would I fix that?
    (plugin is called mcpartyzone btw)

  • #10

    @psychobunny Ah, figured it out, in the plugin.json I called the plugin "mcpartyzone" where it was actually called "nodebb-plugin-mcpartyzone". Now it works, thanks for the help! 馃檪

  • #11

    ahaha okay 馃檪 looking forward to seeing what this mcpartyzone plugin is all about 馃槢

  • #12

    @psychobunny It's a plugin for a Minecraft server website I am developing. (switching over from Enjin)

Suggested Topics

  • 0 Votes
    1 Posts

  • 0 Votes
    8 Posts

  • 0 Votes
    1 Posts

  • 2 Votes
    58 Posts

  • 5 Votes
    6 Posts

| | | |