Is it possible to display previews from child categories when the parent has no posts?
-
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.
-
@esiao already did this on his theme AFAIK. Check out this thread https://community.nodebb.org/topic/2461/accessing-category-children
and his home template file at http://forum.galaxygraph.fr/templates/home.tpl
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.
-
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
-
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.
-
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?
-
@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
-
@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.
https://github.com/NodeBB/NodeBB/issues/2549#issuecomment-69857946