Я пытаюсь, чтобы дочерние страницы апострофов появлялись в моем объекте навигации - однако массив _children всегда пуст.На моей странице есть дочерние страницы, настроенные через пользовательский интерфейс Pages.
Мой index.js для модуля lib / modules / apostrophe-pages содержит следующее:
construct: function(self,options) {
// store the superclass method and call at the end
var superPageBeforeSend = self.pageBeforeSend;
self.pageBeforeSend = function(req, callback) {
// Query all pages with top_menu setting = true and add to menu collection
self.apos.pages.find(req, { top_menu: true }, {slug: 1, type: 1, _id: 1, title: 1})
.children(true)
.toArray(
function (err, docs) {
if (err) {
return callback(err);
}
req.data.navpages = docs;
return superPageBeforeSend(req, callback);
});
};
},
...
Мой атрибут top_menu устанавливается через apostrophe-custom-pages:
module.exports = {
beforeConstruct: function(self, options) {
options.addFields = [
{
name: 'subtitle',
label: 'Subtitle',
type: 'string'
},
{
name: 'css_class',
label: 'CSS Class',
type: 'string'
},
{
name: 'top_menu',
label: 'Include In Top Menu',
type: 'boolean'
}
].concat(options.addFields || []);
}
};
Это дает мне нужные мне страницы с настройкой top_menu ... но я тоже хочу получить дочерние страницы ..
При отладке кода я вижу, что массив docs._children присутствует, новсегда пустой, даже если у страницы есть дочерние страницы ...
Я попытался добавить следующее как в мой app.js, так и в мой index.js, но это не меняет результат:
filters: {
// Grab our ancestor pages, with two levels of subpages
ancestors: {
children: {
depth: 2
}
},
// We usually want children of the current page, too
children: true
}
Как мне получить, чтобы мой запрос find () действительно включал дочерние страницы?