我目前使用以下小部件在主题的第一个帖子之后显示横幅/链接。到目前为止,这运行良好:
<script type="text/discourse-plugin" version="0.8">
const { iconNode } = require("discourse-common/lib/icon-library");
api.decorateWidget("post:after", helper => {
const firstPost = helper.attrs.firstPost;
const h = helper.h;
if (firstPost) {
return h("div#support", [
h(
'a.icon', {
href:'link',
title: 'Support-Icon'
}, iconNode('heart')),
h(
'a.link', {
href: "link",
title: 'Support-Link'
}, 'some text',
),
]);
}
});
</script>
但是,我想将横幅/链接集成到另一个位置——即回复按钮之前。我在下面用红色标记了该位置:
有人能给我一个实现这个目标的提示吗?
我知道位置/作业是由此定义的。问题是如何找到这个 NAME:LOCATION:
api.decorateWidget("NAME:LOCATION", helper => {
Moin
2
您在图片中标记的位置是在主题的所有帖子之后。因此,当有回复时,您的横幅将显示在这些帖子下方,而不是直接显示在第一帖下方。
2 个赞
piffy
3
有一个名为 topic-above-footer-buttons 的插件插槽
这可以帮助您查看它们:
(deprecated) Plugin outlet locations theme component
然后请遵循本指南:
4 个赞
谢谢,它奏效了。
Head 代码示例:
<script type='text/x-handlebars' data-template-name='/connectors/topic-footer-main-buttons-before-create/team-support'>
<div id="support">
<a href="link" title="Support-Icon" class="icon">
<svg class="fa d-icon d-icon-heart svg-icon svg-node" aria-hidden="true"><use xlink:href="#heart"></use></svg>
</a>
<a href="link" title="Support-Link" class="link">text</a>
</div>
</script>
1 个赞
抱歉,该按钮/横幅仅在用户登录时显示。如何确保该按钮/横幅也显示给未注册用户?
我正在使用此主题位置:topic-footer-main-buttons-before-create
system
(system)
关闭
6
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.