讨论模板

|||
|—|—|—|
|:discourse2: | 摘要 | Discourse Templates 允许创建可重复使用的内容模板。模板存储在特殊类别的主题中,在那里可以根据需要进行编辑和讨论。|
|:open_book: | 安装指南 | 此插件已与 Discourse 核心捆绑。无需单独安装插件。

:information_source: 此插件基本上是 Discourse Canned Replies 的新版本,但它更灵活,并且以不同的方式存储模板。

功能

此插件使用一个或多个类别来存储模板以供以后使用。这些类别中每个主题的第一个帖子将用作回复的模板。

这种方法提供了比以前使用 discourse-canned-replies 时更多的功能,因为每个模板都有编辑历史记录,可以有关联的标签,并且后续帖子可以根据需要用于讨论模板内容。

只有可见的主题才会被用作模板,因此未列出和已存档的主题将不会被列出。

该插件还利用类别安全设置来检查哪些用户可以使用模板。如果用户可以读取类别中的主题,那么在撰写器中“插入模板”的选项将可用。用户只能看到他们有权访问的类别中的模板/主题。

可以使用多个父类别和/或子类别来为不同用户组提供不同的模板集,并组织模板。

私人模板

该插件还支持私人模板。私人模板是标记为模板的私人消息。这些消息将对消息作者可用作模板。

已存档的消息不会被列为模板。

:bulb: 您可以在以下位置找到所有私人模板:
/u/{USER-NAME}/messages/tags/{PRIVATE-TEMPLATE-TAG}

设置:

  • discourse templates enabled: 激活插件
  • discourse templates categories: 用于存储模板的类别。这些类别及其子类别中的每个主题都将用作模板,并可供能够在其原始类别中看到它们的用户使用。
  • discourse templates enable private templates: 启用私人模板的使用。
  • discourse templates groups allowed private templates: 允许使用私人模板的用户组。

:warning: 管理员始终被允许。

  • discourse templates private templates tags: 用于将私人消息标记为模板的标签。

如何使用

安装插件后,您需要至少创建一个类别来存储模板。

请注意,有权读取此类别中主题的每个用户都将能够在其撰写器中使用插件功能。

:bulb: 专业提示: 编辑主题的相同设置将应用于“模板”主题。如果您希望该类别中具有写入权限的任何人都能编辑现有模板,则应在类别设置中激活“默认情况下将新主题设为 wiki”。

之后,在插件设置中指定类别。

就是这样。现在您只需在指定类别中创建一些主题,它们就可以用作模板了。

如果需要,您可以创建子类别以更好地组织模板或为多个用户组提供不同的回复集。

要插入模板,您必须先打开回复撰写器,然后单击“更多”按钮,然后选择“插入模板”选项。

选择所需的模板,您可以按文本或标签搜索,然后单击“粘贴”图标。

键盘快捷键

您可以在 PC 上使用 Ctrl+Shift+I 或在 Mac 上使用 +Shift+I 来插入模板。

:bulb: 键盘快捷键在 Discourse 的任何文本区域中都有效。

私人模板

:warning: 私人模板仅在同时启用了私人消息和标签的实例中有效。

您需要配置以下 Discourse 设置才能使其正常工作:

  • tagging enabled:必须启用。
  • enable personal messages:如果您希望该功能对非管理员用户可用,则应启用。
  • pm tags allowed for groups:您需要允许将使用私人模板的用户组标记私人消息。

要使用私人模板,您必须首先在设置中启用它,分配可以使用它的用户组,并分配至少一个用于将 PM 标记为模板的标签。

要创建个人模板,用户必须:

  • 发送一条未加密的私人消息给自己,并使用插件设置中配置的标签之一进行标记。只有消息的作者才能将其视为私人模板。

:bulb: 发送给其他用户的私人消息也可以被标记,但只有消息的作者才能将其用作模板。

预填充变量

该插件支持模板中的以下变量:

  • my_username
  • my_name
  • topic_title
  • topic_url
  • original_poster_username
  • original_poster_name
  • reply_to_username
  • reply_to_name
  • last_poster_username
  • reply_to_or_last_poster_username

以上所有变量都支持回退文本,如果未指定回退并且变量无法替换,则会删除该变量。

标题和正文都支持变量替换。

示例:

Hi %{reply_to_username,fallback:there},

...

Regards,
%{my_name}

如果 reply_to_username 不可用,模板将是:

Hi there,

...

Regards,
Arpit Jalan

discourse-canned-replies 迁移

有一个 rake 任务可以迁移现有的预设回复到模板:

rake "discourse-templates:migrate-from-canned-replies"

在 Meta 上运行此任务仅需几秒钟即可迁移 47 个预设回复,因此除非您有大量预设回复,否则使用它是安全的。

TODO

  • 将功能扩展到撰写器之外的其他地方 :white_check_mark:
  • 允许使用多个父类别作为模板源 :white_check_mark:

更新日志

44 个赞
Canned Replies by Group
Discobot Type Message Automation
Canned respones location
It would be helpful to be able to use the To: username (in PMs) for Templates
Option to allow Category Moderators to use canned-replies?
Canned reply hotkeys?
Poll-restriction
Is it possible to block a category from Upcoming Events?
I'm working to build a "marketplace" on top of Discourse. Would love some suggestions/feedback
Balancing Costs and Functionality in AI-Powered Forums
Canned Replies without extra lines
Canned Replies without extra lines
Add the option to insert the component's 'Reply Template' code to the composer's toolbar
Exploring Discourse as a Learning Management System
Template Button Relocation
Enforce discourse template by category and /or tag
Discourse Category Lockdown
MKJ's Opinionated Discourse Deployment Configuration
Give me some control of how the form template post is styled
Advice on a support forum
Plugin causing errors during rebuild
More efficient (inline) template usage
Will uninstalling a plugin leave any residual debris files in the database?
Build Poll not showing under Post Settings
Feedback on Our Community
How are we all feeling about ChatGPT and other LLMs and how they'll impact forums?
Daily Summary (5am UTC)
General Question About Saved Replies
Using template with a [wrap] code while in Rich Text Editor not working
Bundling more popular plugins with Discourse core
Can I customize the welcome message shown when creating a new topic based on the chosen tag or category?
Using topic templates for categories
Speak with the Discourse product team about moderation
Templates for Staff Notices
Check boxes and Mandatory fields in Topic templates?
Time tracking using Discourse?
Send a message to an inactive group
Canned Replies without extra lines
Discourse template plugin added itself to my discourse?
Community Guide: Activating Lurkers
Ability to Create Private Templates
Ability to Create Private Templates
Plugin causing errors during rebuild