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



  • I was able to hook into the

    filter:groups/details.build
    

    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;
    	callback(null,data);
    }
    

    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.


  • Global Moderator

    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.


  • Global Moderator

    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


Log in to reply
 

Suggested Topics

  • 3
  • 14
  • 4
  • 4
  • 3
| |