使用主题模板进行类别分类

:bookmark: This guide explains how to use topic templates in categories and explores alternative methods for structuring content in Discourse.

:person_raising_hand: Required user level: Administrator

Topic templates are powerful tools for maintaining forum consistency and guiding new users. This guide will walk you through setting up category topic templates and explore alternative methods for structuring content in Discourse.

Summary

  • Learn how to set up category topic templates
  • Discover alternatives like pre-filled topic links and reply templates
  • Understand how to use topics as templates for canned replies

Setting up category topic templates

Category topic templates are useful when you want topics in a specific category to follow a consistent format. Here’s how to set them up:

  1. Navigate to the desired category
  2. Click the :wrench: (wrench) button
  3. Find “Topic Template” in the left menu
  4. Enter your desired template in the text area

For example, a “Movies” category might use this template:

I saw: [insert movie title]

I think it was worth: [how many stars] out of 4 stars

Review here:

:information_source: You can add hidden comments to the template using HTML comments: <!-- I'm an HTML comment -->.

Alternatives to category topic templates

If category topic templates don’t quite fit your needs, consider these alternatives:

Creating pre-filled topic links

You can create URLs that, when clicked, open a new topic with pre-filled information:

  1. Use this URL structure:
    https://discourse.example.com/new-topic?title=topic%20title&body=topic%20body&category=category/subcategory
  2. Modify the parameters as needed

For more details, read the guide on creating new topic links with pre-filled information.

Using reply templates

For topics that require structured replies, consider using the Reply Template theme component:

  1. Install the Reply Template theme component
  2. Set up your desired reply template

Example template:

[wrap=template key="template-name"]
Task list for $tomorrow
- [ ] task 1
- [ ] Clean the <!-- FILL IN ROOM NAME: --> _
[/wrap]

Creating template topics for canned replies

The Discourse Templates plugin allows you to use entire topics as templates for canned replies:

  1. Install the Discourse Templates plugin
  2. Create one or more categories to store your templates
  3. Add topics to these categories, with the first post serving as the template

Additional resources

Last edited by @hugh 2024-07-29T10:13:33Z

Check documentPerform check on document:
20 个赞

也许也可以提及 #form-templates。

这个基本主题模板是否支持占位符来显示发帖人的用户名?类似于 discourse-templates 的功能。

1 个赞

你好,我为我的某个类别创建了一个模板,但在用户创建新主题时没有使用,为什么会这样?谢谢。

似乎该组件阻止了模板的显示:“主题模板占位符文本”

我已停用该组件,现在我的模板可以正常工作了。

2 个赞

我建议添加 topic-templates 标签。