Skip to content

Plugin Development

Have a question about building a plugin? Ask here
426 Topics 1.9k Posts
  • Custom profile fields

    7
    1 Votes
    7 Posts
    3k Views
    N

    @psychobunny is there any option to include plugin client js only for /account/edit endpoint?

    Also, Do you have an ideas, how to augment template for the plugin use - templates/account/edit.tpl? I need add dynamic set of fields to the template, Vanilla's account-edit template is 3 column layout (md:2-5-5), I would like to have (md: 2:4:3:3). Main problem here, that I can't find really abstract approach, solution will be very dependent on Theme... One solution, just replace template on app startup, another option, create set of regexps and try to change template or dom manipulation to get another set of columns. Anyway I'm looking for less dependent solution, so It will not brake with every release of the theme and easily work with another themes

    Taking everything into consideration, I will swap edit.tpl and include client js with a template just as script tag. But maybe you have better ideas 😉

  • 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; });