• Gamers

    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.

  • Gamers

    @sebastián-cisneros no answer for this one?

  • NodeBB

    This took a while to reply because there was a bug in composer-default that needed fixing.

    If you update to composer-default@v7.0.4 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.

  • Gamers

    @baris Thanks for the reply. Will this actually work if I'm using composer redactor?

Suggested Topics

  • 1
  • 3
  • 3
  • 3
  • 3
| |