我有兩種類型的零件之一是作者和第二個是文章。我可以顯示文章列表(在articles-pages
中使用indexAjax.html
和index.html
),因爲它在撇號的Demo和作者列表中執行(使用中的indexAjax.html
和index.html
)。如何將碎片放入其他碎片?
我的問題是,如何使用show.html
文件authors-pages/views
顯示某些指定作者寫入的文章?
因此,當用戶點擊某個作者時,他/她應該能夠看到指定作者寫的文章列表。
的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 [指導](http://apostrophecms.org/docs/tutorials/getting-started/schema-guide.html#code-join-by-array-code)作爲起點。 –
Hi @ robert-jakobson,感謝您的評論。我已經找到了解決辦法。我不想使用'joingByArray',因爲一旦任何文章創建的文章的ID應該被添加到該列表中,因此它會帶來一對一的數據庫文檔之間的鏈接,我認爲這不是一個好主意。 – Karlen