How can I add a script tag to the page from a plugin

Plugin Development
  • I just made my first plugin (yay me) and Im happy enough with it, except for one thing.
    Right now Im adding a script tag to the page using the Custom HTML & CSS, which works but is rather bleh.
    Id like to be able to inject it from code in the plugin some how, so the user doesnt have to add that stuff to the custom html.
    The script tag links to the dropbox dropin api stuff, so it wouldnt be a good idea to down it and link locally.

    I put it on Github incase that helps....
    ...if you wanna see it working its on c9.....

    OH, and its a button for composer that allows you to pick a file from github using its chooser dropin and add its link to the post.

  • You can just stick it in the require call, just tested it on my forum and it worked.

          require(['composer', 'composer/controls', ''], function(composer, controls) {
  • Off course, tha'll work!
    Thanks heaps for that!

Suggested Topics

  • 0 Votes
    1 Posts

    Hi Team NodeBB,

    I am trying to create plugin to add one set image/icon field in the user setting page (user/username/settings) and this value display after user name in topic list page.

    var Plugin = {}; console.log('outside - called properly'); Plugin.addCustomFields = function(hookData, callback) { console.log('Custom Field function is called properly'); // Add your custom fields to the `fields` object here hookData.custom_field_1 = { type: 'text', required: true, title: 'Custom Field 1' }; }; module.exports = Plugin;

    could you please guide me which method i need to use and for image/icon field how to write filed attribute?

  • 0 Votes
    6 Posts

    I can tell u what runFunction() is, I just simplified it for a better understanding.
    Because what I just to replace is this condition if( $.inArray( parseInt(, 10) , CategoriesIds) != -1) instead of going search if the current category is on the array CategoriesIds above (hardcoded), I need to check if the current category is on the selection made by the user on the plugin config page.

    And I'm not realizing how I make that connection between the plugin settings and the function.

    I don't know if I'm making sense to you, but here is the repository with all the code:

  • 1 Votes
    2 Posts

    There's no way to require it. The best you can do is tell the user to do it.

    Also, it use require.main.require instead

  • Hook on a custom page

    Plugin Development
    0 Votes
    11 Posts

    I don't think so, probably something to do with cookies changing. I'm guessing you need to call redirect or status.send to avoid the error.

  • 0 Votes
    3 Posts

    Alternatively, just install it with the --save flag and it will pin the current version in your package.json

    npm install --save sparkpost