【发布时间】:2023-03-15 22:40:01
【问题描述】:
我有两种类型的作品,一种是作者,第二种是文章。我可以显示文章列表(在 articles-pages 中使用 indexAjax.html 和 index.html),因为它在 Apostrophe 的 Demo 和作者列表中实现(通过在 @ 中使用 indexAjax.html 和 index.html 987654328@)。
我的问题是如何使用authors-pages/views的show.html文件显示某些指定作者撰写的文章?
所以当用户点击某个作者时,他/她应该能够看到指定作者撰写的文章列表。
lib/modules/articles/index.js 文件如下
module.exports = {
extend: 'apostrophe-pieces',
name: 'articles',
label: 'Article',
pluralLabel: 'Articles',
contextual: true,
addFields: [
{
name: '_author',
type: 'joinByOne',
withType: 'author',
label: 'Author',
idField: 'author',
filters: {
projection: {
title: 1,
slug: 1,
type: 1,
tags: 1
}
}
},
....
]
};
任何帮助将不胜感激!
【问题讨论】:
-
嗨,Karlen,使用 joinByArray guide 作为起点。
-
嗨@robert-jakobson,感谢您的评论。我已经找到了解决方案。我不想使用
joingByArray,因为一旦创建了任何文章,文章的 id 就应该添加到该列表中,因此它将在 db 文档之间带来一对一的链接,我认为这对于这种特殊情况不是一个好主意。
标签: apostrophe-cms