• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.2 Latest
Buy Hosting

"tag list" to choose from?

Scheduled Pinned Locked Moved Solved Technical Support
5 Posts 2 Posters 559 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • crazycellsC Offline
    crazycellsC Offline
    crazycells
    wrote on last edited by
    #1

    Is it possible to create whitelisted tags for the whole forum , and prevent new tags to be created by regular users?

    So, everyone can only use tags that are pre-determined by the moderators/admins?

    1 Reply Last reply
    1
  • barisB Offline
    barisB Offline
    <baris> NodeBB
    wrote on last edited by
    #4

    Yeah that's correct you would have to do them one by one in the UI. Alternatively if you are going to set all categories to the same 200 tags you can run the below script in your nodebb folder. Update the tags array to the the tags you wan't to allow. This script would delete all existing tag whitelists for all categories then set all categories to same list of allowed tags.

    /* globals require, console, process */
    
    'use strict';
    
    const nconf = require('nconf');
    
    nconf.file({
    	file: 'config.json',
    });
    
    nconf.defaults({
    	base_dir: __dirname,
    	views_dir: './build/public/templates',
    	upload_path: 'public/uploads',
    });
    
    var db = require('./src/database');
    
    // update to your own tags
    const tags = ['tag1', 'tag2', 'tag3'];
    
    db.init(function (err) {
    	if (err) {
    		console.log('NodeBB could not connect to your database. Error: ' + err.message);
    		process.exit();
    	}
    
    	setCategoryWhitelist(function (err) {
    		if (err) {
    			console.error(err);
    			process.exit();
    		}
    		console.log('done');
    		process.exit();
    	});
    });
    
    async function setCategoryWhitelist(callback) {
    	const cids = await db.getSortedSetRange('categories:cid', 0, -1);
    
    	// delete all existing tags
    	await db.deleteAll(cids.map(cid => `cid:${cid}:tag:whitelist`));
    
    	// set new tag whitelist for all categories
    	const bulkAdd = [];
    	cids.forEach((cid) => {
    		tags.forEach((tag, index) => {
    			bulkAdd.push([`cid:${cid}:tag:whitelist`, index, tag]);
    		});		
    	});
    
    	await db.sortedSetAddBulk(bulkAdd);
    	callback();
    }
    
    crazycellsC 1 Reply Last reply
    1
  • barisB Offline
    barisB Offline
    <baris> NodeBB
    wrote on last edited by
    #2

    Yes but you need to do it for each category, under Tag whitelist input.

    crazycellsC 1 Reply Last reply
    0
  • crazycellsC Offline
    crazycellsC Offline
    crazycells
    replied to <baris> on last edited by
    #3

    @baris said in "tag list" to choose from?:

    Yes but you need to do it for each category, under Tag whitelist input.

    I think this requires inputting each tag separately, right? Is there an easy way to do this? Because I am talking about more than 200 tags... And I believe I have to input each tag in each category/sub-category separately, right?

    1 Reply Last reply
    0
  • barisB Offline
    barisB Offline
    <baris> NodeBB
    wrote on last edited by
    #4

    Yeah that's correct you would have to do them one by one in the UI. Alternatively if you are going to set all categories to the same 200 tags you can run the below script in your nodebb folder. Update the tags array to the the tags you wan't to allow. This script would delete all existing tag whitelists for all categories then set all categories to same list of allowed tags.

    /* globals require, console, process */
    
    'use strict';
    
    const nconf = require('nconf');
    
    nconf.file({
    	file: 'config.json',
    });
    
    nconf.defaults({
    	base_dir: __dirname,
    	views_dir: './build/public/templates',
    	upload_path: 'public/uploads',
    });
    
    var db = require('./src/database');
    
    // update to your own tags
    const tags = ['tag1', 'tag2', 'tag3'];
    
    db.init(function (err) {
    	if (err) {
    		console.log('NodeBB could not connect to your database. Error: ' + err.message);
    		process.exit();
    	}
    
    	setCategoryWhitelist(function (err) {
    		if (err) {
    			console.error(err);
    			process.exit();
    		}
    		console.log('done');
    		process.exit();
    	});
    });
    
    async function setCategoryWhitelist(callback) {
    	const cids = await db.getSortedSetRange('categories:cid', 0, -1);
    
    	// delete all existing tags
    	await db.deleteAll(cids.map(cid => `cid:${cid}:tag:whitelist`));
    
    	// set new tag whitelist for all categories
    	const bulkAdd = [];
    	cids.forEach((cid) => {
    		tags.forEach((tag, index) => {
    			bulkAdd.push([`cid:${cid}:tag:whitelist`, index, tag]);
    		});		
    	});
    
    	await db.sortedSetAddBulk(bulkAdd);
    	callback();
    }
    
    crazycellsC 1 Reply Last reply
    1
  • crazycellsC Offline
    crazycellsC Offline
    crazycells
    replied to <baris> on last edited by
    #5

    @baris thanks a lot, this will be helpful.

    1 Reply Last reply
    0
  • crazycellsC crazycells has marked this topic as solved on
  • crazycellsC crazycells referenced this topic on

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development