• 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

Filtering posts based on a few paramaters?

Scheduled Pinned Locked Moved NodeBB Plugins
7 Posts 4 Posters 1.9k 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.
  • Michael Joseph AubryM Offline
    Michael Joseph AubryM Offline
    Michael Joseph Aubry
    wrote on last edited by
    #1

    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.

    Thanks

    A 1 Reply Last reply
    0
  • A Offline
    A Offline
    a_5mith
    replied to Michael Joseph Aubry on last edited by
    #2

    +1, would be good to see.

    1 Reply Last reply
    0
  • psychobunnyP Offline
    psychobunnyP Offline
    psychobunny
    wrote on last edited by
    #3

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

    A 1 Reply Last reply
    1
  • A Offline
    A Offline
    a_5mith
    replied to psychobunny on last edited by
    #4

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

    1 Reply Last reply
    0
  • Michael Joseph AubryM Offline
    Michael Joseph AubryM Offline
    Michael Joseph Aubry
    wrote on last edited by
    #5

    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
    $('form.search').on('submit', function(e) {
        e.preventDefault();
    
        var word = $(this).find('input.searchV').val();
    
        $.ajax({
            url: '/api/search/'+word+'?in=titlesposts',
            type: 'get',
            dataType: 'html',
            success: function (data) {
                var parsed = JSON.parse(data);
                var results = parsed;
    
                console.log(results);
                
                // TODO: pass results.posts into template
                ajaxify.loadTemplate('partials/search_results_topic', function(resultItem) {
                    var html = templates.parse(resultItem, results);
                    $('.topic-list').html(html);
                });
    
            },error: function(data) {
    
                // TODO: error handling
                console.log(data);
            }
        });
    
    });
    
    1 Reply Last reply
    4
  • yariplusY Offline
    yariplusY Offline
    yariplus Community Rep
    wrote on last edited by yariplus
    #6

    fyi You can use $.get as a shortcut function.

    $.get('/api/search/'+word+'?in=titlesposts', function (results) {
      console.log(results);
    });
    
    Michael Joseph AubryM 1 Reply Last reply
    0
  • Michael Joseph AubryM Offline
    Michael Joseph AubryM Offline
    Michael Joseph Aubry
    replied to yariplus on last edited by
    #7

    @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.

    1 Reply Last reply
    0

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