Unsolved Widget code works on one NodeBB instance but not another

  • NodeBB Admin


  • @baris Potentially dumb question, but how do you use this plugin ? There doesn't seem to be any instructions at all??

    Also, there's an error in the console when attempting to use

    Uncaught (in promise) TypeError: n.ColorPicker is not a function
        at HTMLInputElement.<anonymous> (colorpicker.js:11)
        at Function.each (jquery.js:385)
        at C.fn.init.each (jquery.js:207)
        at Object.n.enable (colorpicker.js:8)
        at o (admin.js:31)
        at Object.i.init (admin.js:9)
        at ajaxify.js:357
    
  • NodeBB Admin

    You fork it and make your modifications and publish to npm with a different name like nodebb-plugin-<your-plugin>

    Make sure to rebuild&restart after you install and active.

  • NodeBB Admin

    The colorpicker seems to be an issue with a missing dependency, you can remove that when you fork the plugin.


  • @baris Thanks. Forked, and now ready to insert this

    myPlugin.filterMiddlewarRender = async (hookData) => {
        hookData.templateData.user = await user.getUserData(hookData.req.uid);
        return hookData;
    };
    

    Does this simply get placed in main.js ?

    If I do this, I get

    main.js:19 Uncaught ReferenceError: myPlugin is not defined
        at HTMLDocument.<anonymous> (main.js:19)
        at l (jquery.js:3766)
        at u (jquery.js:3834)
    
  • NodeBB Admin

    No it goes in library.js since it's a server side hook. And you need to add the corresponding entry in plugin.json.

    // library.js
    myPlugin.filterMiddlewareRender = async (hookData) => {
        hookData.templateData.user = await user.getUserData(hookData.req.uid);
        return hookData;
    };
    
    //plugin.json
    "hooks": {
       "filter:middleware.render": "filterMiddlewareRender"
       ...
    }
    
  • Referenced by   phenomlabP   phenomlab 

Suggested Topics

| | | |