How create a new way to order post


  • GNU/Linux

    I need to add a new way to order posts. Now I see this:
    0_1470751588680_ordine.png

    And I need to order posts from the posts that have zero answers to posts that have more answer. I don't know I can do this. Anyone can help me with some codes or with some examples?


  • Plugin & Theme Dev

    @Doppy check the code for "Most posts" and implement it in reverse order.


  • GNU/Linux

    @pichalite thank to your suggest it works I have only topics that aren't "Pin". If I do this:

    0_1470823097376_pinTopic.png

    The topics show in this way:

    0_1470823128648_Schermata del 2016-08-10 11:45:59.png
    In the image I can see that "primo creato " topic that I have PIN it's the last but I want to become the first.

    I want that when I PIN a topic, this must be the first among the topics (now it is the last).

    In plugin.json I put this hook:

    {
    "hook": "filter:category.topics.prepare", "method": "ordina_zero"
    }

    and in library I do this:

    converter.ordina_zero = function(data, callback) {
    
    	//Prendo quale element del sorted ha cliccato
    	user.getSettings(data['uid'], function(err, settings) {
    		if (settings.categoryTopicSort === 'zero') {
    			data.reverse = false;
    			data.set = 'cid:' + data.cid + ':tids:posts';
    		}
    		callback(null, data);
    
    	});
    };
    

    My purpose is show the PIN topic at the beginning and after show the topics with their order. Can you help me?


Log in to reply
 

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.