Composer default category
-
I need a way to setup a default category when you open the composer.
The same way nodebb already does it when you are in a category page, and hit the "new topic" button, but all over the nodebb app.
for example, on the home / landing page (that is loading the categories.tpl) I need to setup 1 category as default and already preselcted when you open the composer.
Im actually not using categories, so, I need to avoid the error of empty category when you post a new topic.
Any ideas? Thanks.
-
@sebastián-cisneros no answer for this one?
-
This took a while to reply because there was a bug in composer-default that needed fixing.
If you update to [email protected] then you can use the below javascript code in your custom javascript tab to force topics into a default category.
require(['hooks'], function (hooks) { app.newTopic = function (cid, tags) { const defaultCid = 2; hooks.fire('action:composer.topic.new', { cid: cid || ajaxify.data.cid || defaultCid || 0, tags: tags || (ajaxify.data.tag ? [ajaxify.data.tag] : []), }); }; });
Replace
defaultCid
with your prefered category id. -
@baris It worked, but... there is one more thing about it.
I have set some Tag Whitelist in that default category, and the tags select dropdown should appear also by default (related to the default category), but it doesn'tis there a way to get this done?
Again thanks for all the help, you are Awesome!.