@sebastián-cisneros In static:api.routes, you'll want to call controllerHelpers.setupAPIRoute to mount the route to the appropriate /api/v3/plugins mount point.
You can see an example of how we do it in the quickstart plugin
Im working with the composer popup (not the one on the blank page). I'm looking for a server hook like filter:composer.build to add new data into that tpl. I couldn't see any hook fired (./nodebb dev) when you open the composer popup.
This is because the popup composer is rendered client side, if you want to add data you should be able to use 'filter:composer.create'
client side. https://github.com/NodeBB/nodebb-plugin-composer-default/blob/master/static/lib/composer.js#L495
@baris that event doesn't seem to be firing. Im using composer redactor.
this is my code in the client side
(function ($) {
// in your plugin client side
$(window).on('filter:composer.create', function(ev, data) {
const postData = data.postData;
const createData = data.createData;
console.log(postData);
console.log(createData);
return {
postData: postData,
createData: createData
}
});
});
})(jQuery);
@sebastián-cisneros said in Composer tpl - add custom data.:
$(window).on('filter:composer.create', function(ev, data) {
Ahh, since this is a filter hook you will have to use the hooks module. Try this
require(['hooks'], function (hooks) {
hooks.on('filter:composer.create', function (data) {
console.log(data);
return data;
});
});
The upside is with the hooks module you can make async requests to the server to get more data and augment the data.createData
object. This wasn't possible with action
hooks.
I am getting the hook to work, but how can I display the new data in the composer.tpl ? so let say before I return the data on the hook, i add data.aName, how can I display {aName} in the template? thx
You need to override the template and add {aName}
into it to display it. Depending on where you want to add it you will have to create a new tpl file that overrides one of the files in https://github.com/NodeBB/nodebb-plugin-composer-default/tree/master/static/templates.