• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.2 Latest
Buy Hosting

3 Category Levels (trimChildren helper)

Scheduled Pinned Locked Moved Technical Support
7 Posts 2 Posters 387 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Matthew PriceM Offline
    Matthew PriceM Offline
    Matthew Price
    wrote on last edited by
    #1

    Our existing forum structure includes an extra level, which we use as a section heading. While this works this prevents our theme from showing the subcategories underneath.

    I have tracked this down to the helpers.trimChildren function, which sets the children variable to undefined as a way of limiting the depth. As we need as extra depth level is there any way of overriding this function without having to resort to modifying core code?

    You can see in these screenshots. The first screenshot is how it looks normally and the second is how we want it to look.

    chrome_51QRCf0bWt.png

    chrome_DU4B8eeX9d.png

    1 Reply Last reply
    1
  • barisB Offline
    barisB Offline
    <baris> NodeBB
    wrote on last edited by
    #2

    I will take a look at this, maybe try to make the depth limit configurable so you can set it to 2 or more.

    Until I add that in you can override that function in your plugin or theme with

    const helpers = require.main.require('./src/controllers/helpers');
    helpers.trimChildren = function (category) {
    	if (Array.isArray(category.children)) {
    		category.children = category.children.slice(0, category.subCategoriesPerPage);
    	}
    };
    

    Keep in mind this will cause the entire category tree to be returned and might make your /categories page load slower if there are a lot of nested categories.

    don't trim children of category if it's a section · Issue #10719 · NodeBB/NodeBB

    right now the /categories page only returns the top level categories and one level of children, everything else is hidden. from https://community.nodebb.org/topic/16538/3-category-levels-trimchildren-helper

    favicon

    GitHub (github.com)

    1 Reply Last reply
    1
  • Matthew PriceM Offline
    Matthew PriceM Offline
    Matthew Price
    wrote on last edited by
    #3

    Thanks for response. Exactly what I was looking for

    barisB 1 Reply Last reply
    0
  • barisB Offline
    barisB Offline
    <baris> NodeBB
    replied to Matthew Price on last edited by
    #4

    @Matthew-Price are you using the section option on the welcome centre category?

    5d16da68-2aff-47f7-901a-24260d064ddc-image.png

    Maybe I can check this setting when trimming the depth and adjust accordingly.

    Matthew PriceM 1 Reply Last reply
    0
  • barisB Offline
    barisB Offline
    <baris> NodeBB
    wrote on last edited by
    #5

    @Matthew-Price take a look at https://github.com/NodeBB/NodeBB/commit/0bec52bc19405fe0c6ef8cdcfd834518ac6b9b8f.

    Let me know if it handles your use case.

    1 Reply Last reply
    0
  • Matthew PriceM Offline
    Matthew PriceM Offline
    Matthew Price
    replied to <baris> on last edited by
    #6

    @baris Yes I am using the 'treat as section' so it would be possible to check this config to determine whether to trim or not.

    barisB 1 Reply Last reply
    0
  • barisB Offline
    barisB Offline
    <baris> NodeBB
    replied to Matthew Price on last edited by
    #7

    @Matthew-Price Yeah I've made this change on our develop branch, if category is marked as section then it won't trim it's second level children.

    1 Reply Last reply
    0
  • julianJ julian moved this topic from NodeBB Development on

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development