# 为 Discourse 添加新内容类型

**URL:** <https://meta.discourse.org/t/adding-new-content-type-to-discourse/154190>\
**Category:** Development\
**Created:** [2020年六月8日 14:44 UTC](https://meta.discourse.org/t/adding-new-content-type-to-discourse/154190 "2020-06-08T14:44:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmed\_Abdelfattah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ahmed_abdelfattah/32/182343_2.png) [@Ahmed\_Abdelfattah](https://meta.discourse.org/u/Ahmed_Abdelfattah)\
**Post date:** [2020年六月8日 14:44 UTC](https://meta.discourse.org/t/adding-new-content-type-to-discourse/154190/1 "2020-06-08T14:44:52Z")

</div>

是否可以为 Discourse 开发一个插件，以添加一种新的内容类型（例如书籍）？该对象将拥有一个包含部分信息和属性的个人资料，用户可以通过标签或额外字段将他们的帖子链接到特定对象。用户能否以众包方式添加新实例（例如新书），而不像分类那样只能由管理员添加？  
这是否是 Discourse 的可行用例？或者我应该考虑其他 CMS？

---

<div class="post-metadata">

**Author:** ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)\
**Post date:** [2020年六月8日 16:13 UTC](https://meta.discourse.org/t/adding-new-content-type-to-discourse/154190/2 "2020-06-08T16:13:37Z")

</div>

回答您的问题：是的，这是可行的，但这需要一个自定义插件，并在前端和后端进行自定义数据处理。具体取决于您希望在何处显示和创建这些信息，其复杂度可能从非常简单（创建独立的路线来创建和显示）到相当复杂且可能不建议采用（使用作曲家插件在主题中创建和显示）不等。

不过，您是否需要在应用中开发新的数据模型，而不是使用带有类别模板的类别？

您可以创建一个 `Books` 类别，然后在类别设置弹窗中，使用“主题模板”部分来定义您希望填写的属性。

---

<div class="post-metadata">

**Author:** ![Ahmed\_Abdelfattah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ahmed_abdelfattah/32/182343_2.png) [@Ahmed\_Abdelfattah](https://meta.discourse.org/u/Ahmed_Abdelfattah)\
**Post date:** [2020年六月10日 16:27 UTC](https://meta.discourse.org/t/adding-new-content-type-to-discourse/154190/3 "2020-06-10T16:27:28Z")

</div>

谢谢 Justin 的回答。  
我基本上希望让用户能够添加自己的 `Books`。目前，非特权用户无法添加新类别。此外，我还希望为每本 `Book` 提供一个包含详细信息、评分和评论的完整页面。
