Skip to content

Plugin Development

Have a question about building a plugin? Ask here
425 Topics 1.9k Posts
  • Plugin registration

    3
    0 Votes
    3 Posts
    2k Views
    barisB

    That error is caused by the following bit of code in src/plugins.js

    paths = paths.map(function(pluginLib) { var parent = path.dirname(pluginLib); return cached.filter(function(libPath) { return libPath.indexOf(parent) !== -1; }); }).reduce(function(prev, cur) { return prev.concat(cur); });

    If paths is an empty array calling reduce will throw that error. We should add better checks to detect that.

  • New Route For Home Page

    2
    0 Votes
    2 Posts
    1k Views
    barisB

    In your plugins init method you can do

    var helpers = module.parent.require('./routes/helpers'); myPlugin.init = function(params, callback) { helpers.setupPageRoute(params.app, '/', params.middleware, [], myCustomHome); callback(); }; function myCustomHome(req, res, next) { async.parallel({ categories: function(next) { Categories.getAllCategories(); } topics: function(next) { Topics.getLatestTopics(); } }, function(err, results) { res.render('myCustomTemplate', results); }); }

    I left out some of the params for the 2 methods you mentioned. Let me know if you can't figure it out.

  • HOOK for intercepting "Register user"

    3
    0 Votes
    3 Posts
    2k Views
    Gauri PadbidriG

    Thanks Julian ! But, what if I want to somehow get the users entered password into that action hook ? Any thing I can do to get the password in the create User HOOK ?

  • Subforums in Nodebb Plugins?

    3
    1 Votes
    3 Posts
    2k Views
    JenklerJ

    Well, except for my work as an IT technician, I have magical powers that can read minds 😛

  • 0 Votes
    2 Posts
    2k Views
    julianJ

    @akumbhare Best bet is to have a client-side file loaded that listens for the action:ajaxify.end hook.

    $(window).on('action:ajaxify.end', function(ev, data) { var url = data.url; });