Subcategories not working as expected.
-
First thanks to @julian & @baris to help me solve my problem with 0.5.1 version resulting in finally testing it out.
As I stated I was needing subcategories and naturally what I did first was to test them.
It works nicely in term of ACP and API but the integration is not working properly.Calling
{categories.parent}
or{categories.parent.value}
in the home template just writes down {categories.parent(.value)} and doesn't retrieve the information correctly.Children are working as expected but are missing one information in my opinion which is the last post (like on topics or on home categories).
My logic of implementation is :
- on home.tpl show categories which don't have parents. (not working cause parents don't work).
- on category.tpl show sub-categories (is working).
I like the fact that the system behind it is so simple that only some tests could respond to other needing.
For example if I want to group a category just set a parent for several of them and change the display on home based on have parents, have children.So if this could work entirely it would be great
Thanks for the implementation and hope this will be fixed soon.
https://github.com/NodeBB/NodeBB/issues/1299 -
After some tests it seems that {categories.parent.value} which works have to be used to test if there's a parent or not. Resulting in something like :
<!-- IF categories.parent.name --> [hide categories with parent] <!-- ENDIF categories.parent.name -->
Just leaving this here if it can help some. I think that while this is working testing categories.parent.length or categories.parent (boolean) would be a better thing.
The weird thing is that you can't negate this test so I'm forced to add a class or add a display none to the categories with parents. That's not the good way I think. What should be the good one is testing if there's a parent and display only categories without it.
Anyway I'm happy I can do what I was planning
-
I'm bumping this. Issue was closed but I don't think it's working as expected and I've found a bug.
First the bug : If you create a category with a parent and then disable it, it will show on front and link to a 404 page.
Also you can't remove a category parent on ACP.Then what's bugging me with the actual subcategories.
Children should have the same information as a category concerning the activity (last posts) because right now subcategories are just links and you don't have any information on it before opening it.I give you an example of my problem in the context.
What I'm trying to do is very simple (no sub-sub-categories)
What I'm working on is displaying parent categories on home by hiding categories with {categories.parent.name} not empty.
As you can see there's no posting information as it should be like here
And the problem is exactly the same in a category page
The first thing I'm trying to do is mimic a theme for categories but since Home and Category are two separate templates there's no problem with that. If the children have the exact same information as parents + their personal information I think that will fix the issue.
One more thing but I think this one is not as important cause more rare but if you want subcategories on subcategories there's a new problem pointing out, subcategories don't have any information about their children (problem is that it could be infinite nesting of json tables).
I 've open an issue on Github linking to this post.
https://github.com/NodeBB/NodeBB/issues/2080 -
@julian Finally tested it out. It's perfect in term of organization it's so much better.
I still have a request though :
Is it possible for subcategories to have this information :
It could be in the clidren object as a table like it is for a category on home.
And theunread-class
attribute too.Why I'm asking this for is because I think the feature of viewing what's said in a category on the homepage should be present also on the categories pages. The reason is simple. If someone post in a subcategory the information doesn't go to the parent (which is perfectly normal) but when you're viewing what's inside you should be able to see if there's new content in a subcategory without loading it like it's done on the homepage.
I don't realize if this is a lot of work cause I think basically it's copying information that was previously here but unusable (subcategories that were displayed on home had this information).Thanks a bunch for what you've already done and I'm happy if I had provide some help.
I think we're near the best thing for subcategories now and that was a needed feature for future versions of NodeBB
-
@julian said:
Keep in mind that I implemented the display of subcategories inside of the category view, so this may have been a duplication of some of the work you did.
I didn't see such "display of subcategories inside of the category viewβ after I installed 0.5.1.....
(may be the following code is not the latest?)
category.tpl
<div class="subcategories">
<!-- BEGIN children -->
<!-- IMPORT partials/category_child.tpl -->
<!-- END children -->
</div> -
@julian said:
@miluo said:
<div class="subcategories"> <!-- BEGIN children --> <!-- IMPORT partials/category_child.tpl --> <!-- END children --> </div>
This is all I added, so if that works for you, then great!
I'm currently working on a way of displaying the sub categories on the home page too. If I come up with something that looks ok. I'll PR it for your approval.
Something like this, but better. Maybe have them before first post teaser instead.
-
@baris said:
@a_5mith IMO they should go under the category name and description, since they are sub categories having them above the main category makes them look like they are more important.
Look at Baris with his logical approach to things. I'll see what can be done.
EDIT: Still a bit of styling left to do. But something like this?
-
The funny thing is, I haven't. I'm not sure what's going on with that. I'll look into it.
I'm making those edits to NodeBBs forum at the minute through the console. Did notice a forum update. So will copy it over to my testing server and edit there.
-
@Developers, is there a reason why the template gets parsed on a cold load, but not when you then go back to the home page?
Code I'm using is basically the same as it is in category.tpl, except I'm calling a new file called category_child_home.tpl instead of editing core template.
EDIT: See here http://a5mith.kd.io:4567/
-
@miluo said:
when user read the posts for a category A, maybe better include those posts from subcategories of A ?
So you mean when a user hovers on a sub category on the homepage, it switches the preview to posts in those child categories? Not sure teasers are included in in the child categories. Could get a bit confusing.