Is it possible to display previews from child categories when the parent has no posts?

NodeBB Development
  • #1


    I've been trying to figure this out for a couple weeks now (in my spare time) without success. I'm beginning to wonder if what I am trying to do is even possible because everything I've tried fails miserably. I'm migrating our forum from phpBB. Because of the way phpBB is designed, our top level categories do not have any posts in them. They simply hold groups of child categories. This results in the home page having no posts previews shown for the top level categories. With the current template system, how can I get the previews to pull from the child categories (if its even possible)? Any help/advice would be very much appreciated.

    Best Regards,

  • #2

    This is a great idea. Also, how about the parent category showing the thread and post count of all the child categories within it. Example: say 2 child categories have 7 posts each, the main category would show 14.

  • #3

    yes.. I'm agree with this 😄

    That would be cool if parent category also showing all posts from it's sub categories

  • #4

    You know, I must say that I am really disappointed in the lack of input from the nodebb devs. This post is my second attempt to get a little advice on how I can make this work. My first attempt was on github where I also received no response from the devs. Being one myself, I fully understand the responsibilities of open source software developers. Though usually when a project's documentation is incomplete the developers make themselves available as much as possible to answer questions. Once the documentation is complete, their won't be as many questions like this. I've tried to figure it out on my own for quite some time before reaching out for advice. I had such high hopes for nodebb but now I am not so sure migrating our forum is the right choice at this point. Its disappointing to say the least. 😕

  • NodeBB

    @esiao already did this on his theme AFAIK. Check out this thread

    and his home template file at

    You just need to get the posts from the child categories instead of the top level categories.

    We try to answer most questions but we are pretty busy.

  • #6

    Thanks. I had already reviewed both of those links extensively but they haven't helped. He is displaying groups of child category blocks on the home page under a header which is basically the name of the parent category. That's not what I'm trying to accomplish. As much time as I have now spent on this I honestly think the current template system is not capable of doing what I need.

    What I want is to show post previews from child categories on the parent block when the parent itself has no posts. @RazorAxis 's suggestion would completely solve this issue though I'd be happy if I could just get the template system to let me do this in the template without the need for any changes to nodebb core. I'm curious why you guys decided to create your own template system when there are at least two well established options already available. Of course, I know hindsight is always 20/20 😉

  • NodeBB

    Isn't what you want to display posts from the child categories on the home page? esiao's template does that it displays the posts(posts previews) under the parent category on the home page. Maybe I am misunderstanding something.

    If you want to only display from child categories when parent has no posts you can check that with

    <!-- IF categories.posts.length -->
    //display from parent
    <!-- ELSE -->
    //display from child
    <!-- ENDIF categories.posts.length -->

    As for the template system I'll let @psychobunny answer that.

  • #8

    @baris, I have no posts in the main categories, with that code you posted make the main catagories show the post count and thread count of the child categories?

  • #9

    No. I'm sorry if my explanation is not clear. Let me try again.. I do not want to display child category blocks on the home page (which is what esiao's template does). I want to display the post previews from child categories inside the parent category block (on the homepage) whenever the parent category has no posts of its own. Does that make sense?

  • GNU/Linux

    @Dustin-Falgout yeah, I get what you mean. It's difficult, and I'll attempt to explain why:

    • The subcategory system is purposefully simple. This was done because it also makes it very flexible.
    • Instead if a category becoming a subcategory, every subcategory has a parent
    • flexibility: You can have theoretically infinitely nested categories.
    • flexibility: You can also have a category be the parent of its own child. NodeBB won't (or shouldn't, anyway) crash in that event.

    ... but because of that simplicity, how do we know how many levels to traverse in order to build the recent posts? If 1, then someone will ask for 2 😉

    If infinite, someone might find a way to blow up the system 😛

  • GNU/Linux

    That's not to say it's impossible or that we won't do it... it'll just take time since we have other priorities 🙂

    Is there a gh issue about this?

  • #12

    @julian Right, I understand. It just makes it difficult to migrate from a more traditional forum like phpBB (which is the most, or perhaps second-most, used forum software today). I think making it easier to migrate from phpBB's format could only help nodeBB gain more ground 🙂 Here is the github issue I opened a couple weeks ago. It was closed, though I hope we can reopen it. I'm more than willing to contribute. Let me know if there's anything I can do.

Suggested Topics

| | | |