Put a forum to top of the index when latest thread is made in there.



  • Hi I need a feature that puts a forum in a top of index when latest thread is made. Is there such plugin? if not, is it posssible to develop by myself?



  • @hentai22 said in Put a forum to top of the index when latest thread is made in there.:

    Hi I need a feature that puts a forum in a top of index when latest thread is made. Is there such plugin? if not, is it posssible to develop by myself?

    this might be what you are looking for:

    https://github.com/julianlam/nodebb-plugin-subcategory-reordering#readme



  • Hi thanks!
    I tried but it didn't work (it only works when I restart the forum but not real time as soon as I post) ! it gives me following error:

    2019-07-01T20:39:54.868Z [4567/22748] - warn: [deprecated] requiring core modules with `module.parent.require('./categories')` is deprecated. Please use `require.main.require("./src/<module_name>")` instead.
    
    2019-07-01T20:39:54.869Z [4567/22748] - warn: [deprecated] requiring core modules with `module.parent.require('./database')` is deprecated. Please use `require.main.require("./src/<module_name>")` instead.
    
    2019-07-01T20:39:54.869Z [4567/22748] - warn: [deprecated] requiring core modules with `module.parent.require('./database')` is deprecated. Please use `require.main.require("./src/<module_name>")` instead.
    
    2019-07-01T20:39:54.869Z [4567/22748] - warn: [deprecated] requiring core modules with `module.parent.require('./database')` is deprecated. Please use `require.main.require("./src/<module_name>")` instead.
    
    2019-07-01T20:39:54.869Z [4567/22748] - warn: [deprecated] requiring core modules with `module.parent.require('./database')` is deprecated. Please use `require.main.require("./src/<module_name>")` instead.
    

    Looks like I need some modifications in actual source codes. What should I replace?
    I use latest nodebb version.


  • Global Moderator

    @hentai22 those are warnings. A warning can be a sign of further issues but in this case there's no problem.



  • then why it didnt work? I said it only worked.after i restarts the forum each time.


  • Global Moderator

    I'm not sure exactly why it didn't work. How did you set it up?



  • just latest version of nodebb then installed it (https://github.com/julianlam/nodebb-plugin-subcategory-reordering#readme). it worked only in the case that I restarted the forum, but not automatially order the forums whenenver any new post is made.

    Help please~



  • About this plugin... https://github.com/julianlam/nodebb-plugin-subcategory-reordering#readme

    When a new topic has been posted in subcategory, the current problem is that it orders that subcategory to top of parent category if and only if I restart the forum, so is working only first time after the forum is rebooted. It was supposed to order the subcategory to top of parent category whenever a new topic/reply is made in that subcategory. Here is code that does it:

    plugin.onNewTopicOrReply = function(data) {
    	var cid = data.topic ? data.topic.cid : data.post.topic.cid;
    	categories.getCategoryField(cid, 'parentCid', function(err, parentCid) {
    		if (parseInt(parentCid, 10) !== 0 && plugin._settings['cid:' + parentCid + ':enabled'] === 'on') {
    			floatToTop(cid, parentCid);
    		}
    	});
    };
    
    function floatToTop(cid, parentCid) {
    	db.sortedSetAdd('cid:' + parentCid + ':children', -Date.now(), cid, function(err) {
    		if (!err) {
    			winston.verbose('[plugins/subcategory-reordering] Floating cid ' + cid + ' to the top of cid ' + parentCid + '.');
    		} else {
    			winston.error(err.message);
    		}
    	});
    }
    

    So it calls floatToTop and db.sortedSetAdd sorts category by date I guess. But the problem is it does not apply real-time but works only after each time the forum is rebooted.

    How can I fix it so that it works real-time?



  • 'cid:' + parentCid + ':children' is cached so that's why the changes aren't reflected realtime. You need to clear the cache after adding to that sorted set with

    const cache = require.main.require('./src/cache');
    cache.del('cid:' + parentCid+ ':children');
    


  • @baris Thank you very much it worked !!


  • GNU/Linux Admin

    Is that change made to my plugin? If so, can you open a pull request to get it in? 😄


Log in to reply
 

Suggested Topics

  • 2
  • 1
  • 3
  • 18
  • 3
| |