What logs are you looking at? Try loading a page while watching ./nodebb log. Also, try running ./nodebb build and restarting.
Enable subcategory description in main page
-
There is an easy way to unlock it ?
-
@r4z3r You have to edit the template. Subcategory description is available in the template.
Like here in Nodebb Category: Plugins
{ "cid":7, "name":"NodeBB Plugins", "description":"Discussion regarding NodeBB Plugin development.", "icon":"fa-wrench", "slug":"7/nodebb-plugins", "topic_count":1041, "order":4, "bgColor":"#333", "link":"", "class":"col-lg-4 col-md-6 col-xs-12", "numRecentReplies":1, "color":"#ffffff", "post_count":10510, "descriptionParsed":"<p>Discussion regarding NodeBB Plugin development.</p>\n", "subCategoriesPerPage":10, "minTags":0, "maxTags":5, "postQueue":1, "parentCid":0, "disabled":0, "isSection":0, "totalPostCount":12763, "totalTopicCount":1550, "tagWhitelist":[ ], "unread-class":"", "children":[ { "cid":17, "name":"Plugin Development", "description":"Have a question about building a plugin? Ask here", "icon":"fa-wrench", "bgColor":"#DC9656", "color":"#ffffff", "slug":"17/plugin-development", "parentCid":7, "topic_count":322, "post_count":1419, "disabled":0, "order":14, "link":"", "numRecentReplies":1, "class":"col-md-3 col-xs-6", "imageClass":"auto", "subCategoriesPerPage":10, "minTags":0, "maxTags":5, "postQueue":1, "isSection":0, "totalPostCount":1419, "totalTopicCount":322, "descriptionParsed":"Have a question about building a plugin? Ask here", "tagWhitelist":[ ], "unread-class":"", "parent":{ "cid":7, "name":"NodeBB Plugins", "description":"Discussion regarding NodeBB Plugin development.", "icon":"fa-wrench", "slug":"7/nodebb-plugins", "topic_count":1041, "order":4, "bgColor":"#333", "link":"", "class":"col-lg-4 col-md-6 col-xs-12", "numRecentReplies":1, "color":"#ffffff", "post_count":10510, "descriptionParsed":"<p>Discussion regarding NodeBB Plugin development.</p>\n", "subCategoriesPerPage":10, "minTags":0, "maxTags":5, "postQueue":1, "parentCid":0, "disabled":0, "isSection":0, "totalPostCount":10510, "totalTopicCount":1041, "tagWhitelist":[ ], "unread-class":"" }, "posts":[ { "pid":82335, "timestamp":1617367530536, "content":"<p dir=\"auto\"><a class=\"plugin-mentions-user plugin-mentions-a\" href=\"https://community.nodebb.org/uid/21579\">@ape</a> the standard way to get nodebb modules is require.main.require</p>\nconst Posts = require.main.require('./src/posts');\nPosts.getPostData(pid, callback)\n", "timestampISO":"2021-04-02T12:45:30.536Z", "user":{ "uid":3076, "username":"PitaJ", "userslug":"pitaj", "picture":"https://i.imgur.com/Dj8Fe85.png", "displayname":"PitaJ", "icon:text":"P", "icon:bgColor":"#e65100" }, "index":4, "cid":17, "topic":{ "slug":"15505/script-to-display-all-posts-by-_id", "title":"Script to display all posts by _id" } } ] }, { "cid":18, "name":"Plugin Requests", "description":"Need a plugin developed? Ask here!", "icon":"fa-comments", "bgColor":"#BA8BAF", "color":"#ffffff", "slug":"18/plugin-requests", "parentCid":7, "topic_count":187, "post_count":834, "disabled":0, "order":18, "link":"", "numRecentReplies":1, "class":"col-md-3 col-xs-6", "imageClass":"auto", "subCategoriesPerPage":10, "minTags":0, "maxTags":5, "postQueue":1, "isSection":0, "totalPostCount":834, "totalTopicCount":187, "descriptionParsed":"Need a plugin developed? Ask here!", "tagWhitelist":[ ], "unread-class":"", "parent":{ "cid":7, "name":"NodeBB Plugins", "description":"Discussion regarding NodeBB Plugin development.", "icon":"fa-wrench", "slug":"7/nodebb-plugins", "topic_count":1041, "order":4, "bgColor":"#333", "link":"", "class":"col-lg-4 col-md-6 col-xs-12", "numRecentReplies":1, "color":"#ffffff", "post_count":10510, "descriptionParsed":"<p>Discussion regarding NodeBB Plugin development.</p>\n", "subCategoriesPerPage":10, "minTags":0, "maxTags":5, "postQueue":1, "parentCid":0, "disabled":0, "isSection":0, "totalPostCount":10510, "totalTopicCount":1041, "tagWhitelist":[ ], "unread-class":"" }, "posts":[ { "pid":82295, "timestamp":1617018854196, "content":"<p dir=\"auto\"><a class=\"plugin-mentions-user plugin-mentions-a\" href=\"https://community.nodebb.org/uid/2\">@julian</a> Hello it doesn't work</p>\n", "timestampISO":"2021-03-29T11:54:14.196Z", "user":{ "uid":20901, "username":"Amir_4", "userslug":"amir_4", "picture":"https://lh3.googleusercontent.com/a-/AOh14Ggw_1MviR2iNN1v-cvJSjfUp7weiHzhphjKFVs6=s96-c", "displayname":"Amir_4", "icon:text":"A", "icon:bgColor":"#33691e" }, "index":3, "cid":18, "topic":{ "slug":"15479/steam-login", "title":"Steam login" } } ] } ], "posts":[ { "pid":82348, "timestamp":1617481846069, "content":"<p dir=\"auto\"><a class=\"plugin-mentions-user plugin-mentions-a\" href=\"https://community.nodebb.org/uid/1\">@baris</a> Ok that's a understandable point. 👍 I try to understand it. Thank you for your help. 👍</p>\n", "timestampISO":"2021-04-03T20:30:46.069Z", "user":{ "uid":19253, "username":"dogs", "userslug":"dogs", "picture":"/assets/uploads/profile/19253-profileavatar-1609661611394.jpeg", "displayname":"dogs", "icon:text":"D", "icon:bgColor":"#827717" }, "index":6, "cid":7, "topic":{ "slug":"13368/get-user-data-from-a-custom-field", "title":"Get user data from a custom field" } } ], "teaser":{ "url":"/post/82348", "timestampISO":"2021-04-03T20:30:46.069Z", "pid":82348, "topic":{ "slug":"13368/get-user-data-from-a-custom-field", "title":"Get user data from a custom field" } } },
You can edit the corresponding template.
Lets say itsyourtheme/templates/categories.tpl
You can access these data inside your theme file like so:
{{{each categories}}} <!-- loops trough the categories array --> {{{ each categories.children }}} <!-- loops trough the current categories children array --> <!-- prints out children category name --> <h3>{categories.children.name}</h3> {{{ end }}} {{{end}}}
Result:
Here are my categories:
This is the rendered template:
You can view available and accessable data if you prepend api to the route.
Route:
https://community.nodebb.org/topic/15523/enable-subcategory-description-in-main-page
API Route with data:
https://community.nodebb.org/api/topic/15523/enable-subcategory-description-in-main-page
So in your case you have two fields available:
"description": "Its a short description here.", "descriptionParsed": "<p dir=\"auto\">Its a short description here.</p>\n"
And you can use this in your template too. Here I use
description
notdescriptionParsed
:{{{each categories}}} <!-- loops trough the categories array --> {{{ each categories.children }}} <!-- loops trough the current categories children array --> <!-- prints out children category name --> <h3>{categories.children.name}</h3> <!-- Check if description for that subcat is available or not --> {{{ if categories.children.description}}} <p>{ categories.children.description }</p> {{{ end }}} {{{ end }}} {{{end}}}
The second Subcat has no description. So there it is empty:
-
@dogs
Okay, that's great, thank you.