I changed my function to get children in data.templateValues.categories :
library.onRenderHeader = function (data, callback) {
// Get all the visible categories.
Categories.getCategoriesByPrivilege('categories:cid', data.req.uid, 'find', function (err, categories) {
if (err) {
return callback(err, data);
}
categories=Categories.getTree(categories);
// Send the data for use by template...
data.templateValues.categories = categories;
console.log(categories);
callback(null, data);
});
};
With this, the console.log(categories); command shows that children are populated on server :
[ { bgColor: '#A1B56C',
cid: 39,
class: 'col-md-3 col-xs-6',
color: '#fff',
description: '',
descriptionParsed: '',
disabled: 0,
icon: 'fa-graduation-cap',
imageClass: 'cover',
link: '',
name: 'Vie de classe',
numRecentReplies: 1,
order: 1,
parentCid: 0,
post_count: 0,
slug: '39/vie-de-classe',
topic_count: 0,
isSection: 0,
totalPostCount: 0,
totalTopicCount: 0,
tagWhitelist: [],
'unread-class': '',
children: [ [Object], [Object], [Object], [Object] ],
parent: undefined },
{ bgColor: '#7CAFC2',
cid: 24,
class: 'col-md-3 col-xs-6',
color: '#fff',
description: '',
descriptionParsed: '',
disabled: 0,
icon: 'fa-cubes',
imageClass: 'cover',
link: '',
name: 'Mathématiques',
numRecentReplies: 1,
order: 2,
parentCid: 0,
post_count: 0,
slug: '24/mathématiques',
topic_count: 0,
isSection: 0,
totalPostCount: 3477,
totalTopicCount: 408,
tagWhitelist: [],
'unread-class': '',
children:
[ [Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object] ],
parent: undefined },
{ bgColor: '#A16946',
cid: 11,
class: 'col-md-3 col-xs-6',
color: '#fff',
(cutted here to be short...)
but no success on display on client (no children in dropdowns...).
????