Filtering posts based on a few paramaters?

NodeBB Plugins
  • I have a few ideas about plugins. I want to use solr to create a plugin that updates the view in an ajax fashion. So basically on each keypress I ask for some data and in realtime update the list of posts/topics.

    I also want to have a filtering dropdown that allows me to select if I want to view the "latest" posts, "popular posts", or "unanswered" posts while updating the list in realtime.

    Normally I would use angular, or backbone for a job like this, theoretically I could implement them and copy the template from my theme into a client side template and hack like that, but its messy.

    I am curious how can I make some calls i.e solr/filterBy then use the response to update the view in a NodeBB way?

    I can dig into some existing plugins, but I want to ask here for some insights and possibly be pointed towards themes/plugins that have similar like features. I know NodeBB is already using ajaxify, so I could read more about it and maybe I can do something with that.


  • +1, would be good to see.

  • We do something similar in groups details page (the member search). It's nothing special just jquery

  • @psychobunny Sooooo it could be factored into tags and categories? 😛

  • Ok so I have successfully done this with solr!

    This is probably obvious to all expert nodebb people here, but for me I had to really look at the source code/docs/google to understand how the eco system works.

    After configuring the nodebb-plugin-solr the api call out of the box looks like /api/search/KEYWORD?in=titlespost I am still trying to figure out how the plugin is hooked up with the core and how this route triggers the solr query.

    Simply with ajax I just make a get request to the route and with the response I see now how I can use ajaxify.

    // search function
    $('').on('submit', function(e) {
        var word = $(this).find('input.searchV').val();
            url: '/api/search/'+word+'?in=titlesposts',
            type: 'get',
            dataType: 'html',
            success: function (data) {
                var parsed = JSON.parse(data);
                var results = parsed;
                // TODO: pass results.posts into template
                ajaxify.loadTemplate('partials/search_results_topic', function(resultItem) {
                    var html = templates.parse(resultItem, results);
            },error: function(data) {
                // TODO: error handling
  • fyi You can use $.get as a shortcut function.

    $.get('/api/search/'+word+'?in=titlesposts', function (results) {
  • @yariplus lol yeah would be more simpler, I know about that method, but I went with the longer approach because my first few tries I had issues so I made assumptions that it was data type or something. Thanks though, that method definitely makes the code look cleaner.

Suggested Topics