Do an action when users go to topics

NodeBB Development
  • Hello guys. First I need apologize for my bad expression because in this moment I'm learning English and my control of the English language is very poor.

    My problem is the next, I'm developing a plugin that allows users to write special tags in title (For example, "+nsfw" or "+private". This tags grant some features to post. What hook do I need use?

    In this moment I have that, but it doesn't work.


      "id": "nodebb-plugin-tagstitle"
    , "name": "Special Tags in Title for NodeBB"
    , "description": "This plugin allows users create new topics with special restrictions with special tags, for example, +hd, +prv, +nsfw..."
    , "url": ""
    , "library": "./library.js"
    ,"hooks": [
    	{ "hook": "filter:category.topics.get", "method": "goPage" },


    Topics = module.parent.require('./topics'),
    User = module.parent.require('./user'),
    var TagsTitle = {};
    	TagsTitle.goPage = function(postData) {
    	//Conseguimos el título del post en minúsculas
    	var topicTitle = function() {
    		var topicTitle = postData;
    		var topicTitleLower = topicTitle.toLowerCase();
    		return topicTitleLower;
    	//Analizamos si existe el título o no para aplicar medidas
    	if(topicTitle == null) {  
    	//Don't do anything  
    	console.log('Título sin etiquetas');
    	else {
    		console.log('Título con etiquetas');
    		if(topicTitle.includes('+hd') == true)
    			//The topic titles contains +HD
    		else if(topicTitle.includes('+prv') == true)
    			//The topic titles contains +prv
    		else if(topicTitle.includes('+18') == true)
    			//The topic titles contains +18
    		else if(topicTitle.includes('+nsfw') == true)
    			//The topic titles contains +nsfw
    module.exports = TagsTitle;
  • Your if statement is wrong. It should be if (topicTitle == null) or if (!topicTitle)

  • Thanks, I have just solved the error.

    But the code doesn't work for now. How can I do execute a function when user go to topic?


Suggested Topics