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

: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

20 个赞
Is there a way to make an input form for structured data?
How to add information while user creates post
How to optimize issue/support ticket like workflow?
Is it possible to have a questionnaire topic?
Can I add new fields to a topic?
Replies with specified fields
Using Discourse as a personal Journal?
Optimized interface for mass editing topic titles?
How to hide placeholder from message composer
Topic template is confusing on mobile
Feature request: duplicate posts
Building a practitioner directory or category in a community
Plugin to gather approvals / signatures on an initiative?
How to include the label/text on the post creation textbox?
Auto-Populating Category Topic Templates with Usernames
Does this platform not give users templates when creating posts?
Forms on Discourse
Custom Topic Fields
Can I customize the welcome message shown when creating a new topic based on the chosen tag or category?
Alerts that react to the user
Discourse Workflow
Use URL to compose a new message, with `body` adding new lines
Replace "+ New Topic" with "+ Create Event" option
Reply Template
Custom topic fields per category or custom topic entry form per category?
How can I set up a reminder banner in the editor?
Structuring an active support community migrating from Facebook
Thoughts from the Elm community on Intentional Communication
Are the tables on top of some posts markdown or a feature?
Discourse/jobs?
Custom post warning for categories
Sending a message upon post
Topic template is confusing on mobile

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

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

1 个赞

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

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

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

2 个赞

我建议添加 topic-templates 标签。