Showing Subcategories on the Mainpage with 0.9.3
-
Hello everyone,
I modified the Persona Theme so that Subcategories are shown on the Mainpage and not only on the Category-Page. That worked well so far in 0.8.3; I just modified the templates/categories.tpl by adding basically this:
[...]
<!-- BEGIN categories -->
<!-- IMPORT partials/categories/item.tpl -->
<!-- IF categories.children.length -->
<!-- BEGIN children -->
// HTML Representation of a Subcategory
<!-- END children -->
<!-- ENDIF categories.children.length -->
<!-- END categories -->
[...]That gave me a Overview like this:
After upgrading to 0.9.3, I dont get this to work anymore. If I use my old code above, NodeBB logs following Stacktrace:
error: RangeError: Maximum call stack size exceeded
at String.match (native)
at checkConditional (/path/to/nodebb/node_modules/templates.js/lib/templates.js:224:26)
at checkConditionals (/path/to/nodebb/node_modules/templates.js/lib/templates.js:220:27)
at parseValue (/path/to/nodebb/node_modules/templates.js/lib/templates.js:386:14)
at parse (/path/to/nodebb/node_modules/templates.js/lib/templates.js:405:17)
at cleanup (/path/to/nodebb/node_modules/templates.js/lib/templates.js:476:27)
at parse (/path/to/nodebb/node_modules/templates.js/lib/templates.js:422:15)
at cleanup (/path/to/nodebb/node_modules/templates.js/lib/templates.js:476:27)
at parse (/path/to/nodebb/node_modules/templates.js/lib/templates.js:422:15)
at cleanup (/path/to/nodebb/node_modules/templates.js/lib/templates.js:476:27)
RangeError: Maximum call stack size exceeded
at String.match (native)
at checkConditional (/path/to/nodebb/node_modules/templates.js/lib/templates.js:224:26)
at checkConditionals (/path/to/nodebb/node_modules/templates.js/lib/templates.js:220:27)
at parseValue (/path/to/nodebb/node_modules/templates.js/lib/templates.js:386:14)
at parse (/path/to/nodebb/node_modules/templates.js/lib/templates.js:405:17)
at cleanup (/path/to/nodebb/node_modules/templates.js/lib/templates.js:476:27)
at parse (/path/to/nodebb/node_modules/templates.js/lib/templates.js:422:15)
at cleanup (/path/to/nodebb/node_modules/templates.js/lib/templates.js:476:27)
at parse (/path/to/nodebb/node_modules/templates.js/lib/templates.js:422:15)
at cleanup (/path/to/nodebb/node_modules/templates.js/lib/templates.js:476:27)and restarts everytime he tries to load the theme, so nodebb is only working if I switch themes. I'm running NodeJs 4.2.3 (with 0.10 it didnt work either and the error was undefined undefined).
I played around a bit and found out that it dies when I try to call <!-- BEGIN children -->. I also tried to call <!-- BEGIN categories.children --> (wont work) and tried to move the inclusion to templates/partials/categories/item.tpl as
<!-- IF ../children -->
<!-- BEGIN children --><!-- END children -->
<!-- ENDIF ../children -->This gives me the same Exception with a slightly different stacktrace
RangeError: Maximum call stack size exceeded
at new RegExp (native)
at makeConditionalRegex (/path/to/nodebb/node_modules/templates.js/lib/templates.js:202:10)
at checkConditional (/path/to/nodebb/node_modules/templates.js/lib/templates.js:224:32)
at checkConditionals (/path/to/nodebb/node_modules/templates.js/lib/templates.js:220:27)
at parseValue (/path/to/nodebb/node_modules/templates.js/lib/templates.js:386:14)
at parse (/path/to/nodebb/node_modules/templates.js/lib/templates.js:405:17)
at cleanup (/path/to/nodebb/node_modules/templates.js/lib/templates.js:476:27)
at parse (/path/to/nodebb/node_modules/templates.js/lib/templates.js:422:15)
at cleanup (/path/to/nodebb/node_modules/templates.js/lib/templates.js:476:27)
at parse (/path/to/nodebb/node_modules/templates.js/lib/templates.js:422:15)
RangeError: Maximum call stack size exceeded
at new RegExp (native)
at makeConditionalRegex (/path/to/nodebb/node_modules/templates.js/lib/templates.js:202:10)
at checkConditional (/path/to/nodebb/node_modules/templates.js/lib/templates.js:224:32)
at checkConditionals (/path/to/nodebb/node_modules/templates.js/lib/templates.js:220:27)
at parseValue (/path/to/nodebb/node_modules/templates.js/lib/templates.js:386:14)
at parse (/path/to/nodebb/node_modules/templates.js/lib/templates.js:405:17)
at cleanup (/path/to/nodebb/node_modules/templates.js/lib/templates.js:476:27)
at parse (/path/to/nodebb/node_modules/templates.js/lib/templates.js:422:15)
at cleanup (/path/to/nodebb/node_modules/templates.js/lib/templates.js:476:27)
at parse (/path/to/nodebb/node_modules/templates.js/lib/templates.js:422:15)Has anyone an idea why this isn't working anymore/where my mistake is? What is causing this error? I would really like my subcategories back at my mainpage.
Thanks for your help!
-
@Saari
templates.js
had a bug. update templates.js to v0.3.2npm i [email protected]
you will have to update package.json and change templates.js version to 0.3.2 otherwise NodeBB won't start/restart
after the upgrade try this...
<!-- BEGIN categories --> <!-- IMPORT partials/categories/item.tpl --> <!-- BEGIN children --> //your subcategory code... use categories.children.key syntax here <!-- END children --> <!-- END categories -->
you don't have to check for children length...
<!-- BEGIN children -->
won't do anything if children is empty -
Just to butt in here, is this the same method this forum (NodeBB) uses to add sub categories to the categories listing, or is it done another way?
-
@Danny-McWilliams said:
Just to butt in here, is this the same method this forum (NodeBB) uses to add sub categories to the categories listing, or is it done another way?
According to persona subcategory
https://github.com/NodeBB/nodebb-theme-persona/commit/3b7213fcc295c92610c0d2896a9632ae3b825cb5 -
Only option is to pull from git. When will it be available on ACP?
-
@Danny-McWilliams You will need the master branch of NodeBB or latest from v1.x.x branch for that to work.
-
Thanks @pichalite I'm currently on v1.0.0. It'd be nice to have, but I think I should just get my forum online again before looking at cosmetic alterations!