回复模板

||||\n-|-|-|\n:discourse2: | 摘要 | 回复模板 (Reply Template) 可让您轻松地在回复或新主题中重复使用帖子的一部分内容。\n| :eyeglasses: | 预览 | 在 Discourse 主题创建器中预览\n:hammer_and_wrench: | 仓库链接 | \u003chttps://github.com/discourse/discourse-reply-template-component\u003e\n:open_book: |初次接触 Discourse 主题? | Discourse 主题使用入门指南\n\n[wrap=theme-install-button repoUrl="https://github.com/discourse/discourse-reply-template-component\" repoName="Discourse Reply Template"]\n安装此主题组件\n[/wrap]\n[quote]\n\n:discourse2: 由于这是由 Discourse 团队维护的 official 主题组件,您可以在 Meta 上的相应版块中提出 #support、#bug、UXFeature 请求,并附上适当的主题组件标签。点击下面的链接即可开始。:+1: \n\n\u003ckbd\u003e [:question:\u0026nbsp;支持](Discourse Meta "就 Reply Template 的配置和使用寻求支持") \u003c/kbd\u003e \u003ckbd\u003e [:bug:\u0026nbsp;Bug](Discourse Meta "Bug 报告意味着某些东西坏了,阻止了主题组件的正常/典型使用") \u003c/kbd\u003e \u003ckbd\u003e [:eyes:\u0026nbsp;用户体验](Discourse Meta "关于 Reply Template 的用户界面,以及功能的呈现方式(包括语言和 UI 元素)的讨论") \u003c/kbd\u003e \u003ckbd\u003e [:bulb:\u0026nbsp;功能](Discourse Meta "讨论如何改进或增强现有的 Reply Template 功能,以及提议的新功能将如何运作")\u003c/kbd\u003e\n\n[/quote]\n\n### 功能\n\n回复模板 (Reply Template) 可让您轻松地在回复或新主题中重复使用帖子的一部分内容。\n\n### 用法\n\n\n[wrap=template key=\"template-name\"]\n我的可重用内容\n\n- [ ] 任务 1\n- [ ] 任务 2\n[/wrap]\n\n\n请注意,如果用户未登录,点击按钮将显示登录模态框。\n\nkey 是必需的\n\n### 其他选项\n\n- action=\"create\" 这将使按钮打开一个撰写器以创建新主题\n- action=\"create_pm\" 这将使按钮打开一个撰写器以创建新私信 (PM)\n- categoryId=\"2\" 仅可与 action=\"create\" 一起使用,将设置打开的撰写器的分类\n- title=\"some title\" 仅可与 createcreate_pm 一起使用,主题/私信的标题\n- recipients=\"a@example.com\" 仅可与 create_pm 一起使用,将发送给的人员\n- usernames=sam 仅可与 create_pm 一起使用\n- label=\"My button text\" 按钮文本\n\n\n### 占位符\n\n您的模板中可以有特殊的 key,它们将被替换:\n\n- \$week_start → 本周开始的日期\n- \$week_end → 本周结束的日期\n- \$prev_week_start → 上一周开始的日期\n- \$prev_week_end → 上一周结束的日期\n- \$today\n- \$tomorrow\n- \$username → 当前用户的用户名\n- \$name → 当前用户的名称 \n\n请注意,这将替换为本地日期。\n\n特殊占位符也会在 title 中进行插值处理\n\n### 标签列表\n\ntagsList=\":heart:,foo,#bar" 将在模板末尾显示一个复选框列表,以便人们可以轻松地为帖子添加标签。\n\n

\n\n## 示例\n\n\n我的待办事项列表 $week_end\n\n- [x] 任务 1\n- [x] 任务 2\n\n\n### 设置\n\n| 翻译 | 默认值\n|-|-|\n| discourse_reply_template_component.use_template_reply | 将模板用作回复\n| discourse_reply_template_component.use_template_create | 将模板用作新主题\n| discourse_reply_template_component.use_template_create_pm | 将模板用作新私信\n| discourse_reply_template_component.needs_key | 每个模板都需要一个 key 属性。例如:[wrap=template key=\"weekly_status\"][/wrap]\n\n\u003cbr\u003e\n\n\u003e:discourse2: 由我们托管? 标准版、商业版和企业版套餐均可使用主题组件。

43 个赞

I was wondering can this be used in a specific category/sub?

Ie bug reporting form?

3 个赞

Yes :arrow_down:

E.g.
[wrap=template key="bug-report" action="create" categoryId="your-bug-category-id"]

9 个赞

Thank you will need to explore this more.

This is the best. Thank you!! I use this to create checklist templates that can be created anytime we’re doing a repetitive project. Before, our instructions would have been “copy and paste everything below” instead of having this very elegant button to create a topic for people.

5 个赞

Is there a plan to make this functionality accessible in the composer window? To me the most logical place being where things like Hide Details and Build Poll live.

3 个赞

I just updated the component, see OP for usage but a quick note:

  • placeholder dates are now replaced by local dates
  • you can now define a tagsList

8 个赞

Thank you for a great component!

It’s impossible to add a poll in the wrap. Can you add this functionality?

[wrap=template key="template-name"]

[poll type=regular results=on_vote chartType=bar]
# Who will join?
* 1
* 2
* 3
[/poll]

[/wrap]

I added more locales to your component and created a PR. Please, check.

1 个赞

How can i install this component?

In my opinion it’d be more helpful to have an example for the reply case (without action=create) because this is probably the reason, the majority is searching for since creating a topic is already possible via URL

My try:

  • ok
  • fail
2 个赞

Would it be possible to use a template to create a new personal message?

Also, when someone is not signed in, clicking on “Use template as reply” does not result in any action. Could you add functionality where if a user is not logged in, something happens to nudge them to log in or create a new account?

4 个赞

Great suggestion, it’s done, I updated the OP.

4 个赞

Is there a way to pre-populate the title of a new topic?

Is there a way to automatically add tags instead of having just the tag list?

4 个赞

No, but that’s reasonable feature request for sure. I’m kinda full ATM but making a note of this, thanks.

5 个赞

Is there any possible way to modify the stock reply button in a topic with such a template?
That would be a gamechanger for specific structured conversations in the forum. Especially for contests etc where users have to submit content in a structured manner.

1 个赞

Hi, sorry I don’t understand your request, can you be more specific please ?

Currently the user can access the reply template only via the button in the first post generated by the theme component.
What I would like to achieve is to enable the template for the stock reply buttons in the topic as well (reply button below the timeline and reply button below the last post)

Edit: One prolific use case is a topic where users can leave feedback like bug reports etc. If we could add per-topic post templates just like for per-category templates for new topics, that would lead to less incomplete reports and hence save our staff a lot of time.

5 个赞

您好,

我在安装此组件时遇到了一些问题。我是 Discourse 的新手,希望有人能确认我所采取的步骤是否正确。

我遵循了此处的指南 Installing a theme or theme component 来安装该组件。我已经将该组件包含在我们所有的主题中。

但是,当我创建一个新主题并包含

我的可重用内容

  • 任务 1
  • 任务 2

时,没有“使用模板作为回复”按钮。例如:

它只是显示了模板周围的包装器。我是否遗漏了某个步骤?我是否需要自定义代码中的某些内容?

另外,Discourse 提示主题在 CSS、HTML 或 YAML 中存在错误。我不确定这是否与按钮不显示有关?

感谢您的任何帮助。

明天会看一下

2 个赞

谢谢。我被告知这可能也是我们运行的 Discourse 版本的问题,但我们会再回来讨论这个问题。