你好 ![]()
感谢这个组件
它完美地契合了我现在想要实现的目标。实际上,我最初的想法是,如果能与 回复模板 组件结合使用就太棒了。但遗憾的是,正如上面的帖子所解释的,这是不可能的。![]()
我找到了一个变通方法,可以用作模板,它与 链接到新主题 和 链接到新个人消息 一起使用。
这是我的做法:
- 创建一个占位符表单(为简单起见,我使用了 OP 中的示例)
Your email: =NAME=-=COUNTRY=@example.com
- 创建一个新主题的链接:
我在链接中设置了: - 类别
- 标题
- 正文
如果你想添加空行,请使用 \,这样它就不会破坏链接,或者为了让它不可见,你可以使用 ,它会在新行中添加一个空格。它将成为模板的一部分,并创建空行,
<a href="https://meta.discourse.org/new-topic?category==CATEGORY=&title=This is a topic created by =NAME=&body=Hello :wave:
This is a test topic... Let's see the placeholder form.
\
Your email: =NAME=-=COUNTRY=@example.com">Use template as new topic</a>
- 创建一个主题预览
Selected category
=CATEGORY=
Topic title
This is a topic created by =NAME=
Topic body
Hello
This is a test topic… Let’s see the placeholder form.
Your email: =NAME=-=COUNTRY=@example.com
- 创建“用作新主题的模板”按钮(在上面的示例中,这是一个链接,你可以将其制作为按钮)
用这个文本创建一个 [wrap] 元素。这使得它可以通过 CSS 进行定位和样式设置。我将其添加到下面。
<a href="https://meta.discourse.org/new-topic?category==CATEGORY=&title=This is a topic created by =NAME=&body=Hello :wave:
This is a test topic... Let's see the placeholder form.
\
Your email: =NAME=-=COUNTRY=@example.com">[wrap=template-button]Use template as new topic[/wrap]</a>
样式化 [wrap=template-button]
类似这样 ![]()
Common / CSS
[data-wrap="template-button"] {
background: var(--tertiary);
color: var(--secondary);
border-radius: var(--d-button-border-radius);
padding: 0.5em 0.65em;
transition: background 0.25s;
&:focus,
&:hover {
background: var(--tertiary-hover);
color: var(--secondary);
}
}
模板按钮看起来会像这样 ![]()

演示
希望这个小教程能帮助到需要类似功能的人 ![]()
编辑:我设置了一个类别选择器,它增加了在不同类别中创建主题的功能。