Whats the easiest way to limit the group posts to only show the posts for that specific group?

Plugin Development
  • I was able to hook into the


    And do something simple to filter like this:

    plugin.groupDetail = function(data,callback){
    	let f = data.templateData.posts.filter(p=>data.templateData.group.name === p.category.name);
    	data.templateData.posts = f;

    The result was that it limited the results on the group details to only reflect the posts that match the category. However, I then will need to requery the database and re-render the data and re-generate new objects to get more posts that belong only to this specific category.

    All I simply want to do is make the group details only show the posts that belong to that specific group. Currently the nodeBB is showing all of the posts that a member of the group has made even when the posts could be from a totally different group.

    Any suggestions or advice, greatly appreciated. I am trying to avoid making changes to nodebb base and do all of this from my plugin.

  • So what's the problem you're having? Sometimes no posts show up because the last 20 or so posts were all in other categories?

  • @PitaJ When I filter out the posts that do not belong to the group .... I am left with a smaller amount of posts... I need to get more posts to fill the page.

    When the page renders the posts in the group... I am filtering out all of the member posts that do not belong to that group.... NodeBB appears to provide the last 10 posts from the members that are part of that group.

    If the top 10 that are coming back have for example 8 of them that posts from a different group ... I am filtering them out.. I dont want to see them since they are not from the group the user is currently viewing.

    When I do this, I only have 2 remaining that are associated to the group that the user is viewing. I need to now figure out how I can get another 8 of them that do belong to the group that they are viewing.

    Hope this makes things a bit clearer.

    NodeBB for whatever reason is showing both the posts made inside the group being viewed by the member but also the posts the member made in other groups.

    I dont want to show any of the posts made by the members from other groups. I only want to show the posts made inside the actual group being viewed. My filter is removing those posts made in outside groups by these members. When I filter I am left with a small remaining amount to show on the template.

  • Unfortunately there's no easy way to do this besides what you said: fetching more posts and filtering them yourself.

  • Im going to have to do some f*kery on this. Let the hacks begin

  • @jzbg

    This feature is something I've always wanted too...

Suggested Topics

  • 0 Votes
    11 Posts

    That's not possible out of the box, you would have to write a plugin to set the groupTitle value to all the groups the user is a member of.

  • 1 Votes
    4 Posts

    And also if you guys want more third-party developers to make plugins for nodebb, you should write the development docs properly that other developers can contribute. I had a hard time in figuring out the things while writing my first plugin for nodebb.

  • 0 Votes
    3 Posts

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


    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?

  • 0 Votes
    9 Posts

    Cool! Just signed it.

  • 0 Votes
    3 Posts

    @baris thanks. I realised there's some issues with redactor munging the data.
    When code is insered inside a <pre/> block, switching between HTML and WYSIWYG views will munge the content to HTML entitites.
    You can recreate this issue on this page:

    Switch to code view and add some HTML inside the <pre/> block. I entered:
    Switch to WYSIWYG and back to code and it has been replaced by:


    This breaks the ability to parse that code later with syntax highlighters.

    I've raised it with Imperavi.