一个小型组件,用于在用户个人资料中添加可自定义的链接。
显示在…
-
展开的用户个人资料
-
用户卡片
设置
如果留空 profile custom link field,它将默认使用用户名,因此在示例情况下,它将转到
http://github.com/charlie
如果要使用自定义用户输入字段,您必须将值设置为用户字段的确切名称,例如:
-
创建用户字段
-
将设置设置为用户字段名称
-
让用户填写字段
/u/[username]/preferences/profile
现在它将转到 http://github.com/MyRealGithubName
有关更高级的实现,请查看 Multiple Custom Profile Links component
21 个赞
mattdm
(Matthew Miller)
2
这会获得“nofollow”吗?它会被发送给 Akismet 吗?
这绝对会被垃圾邮件发送者利用!
1 个赞
Firepup650
(Firepup Sixfifty)
3
只是一个小小的建议,应该是 http://github.com/,对吧?
另外,有什么特别的原因建议使用 http GitHub 而不是 https 吗?
4 个赞
哈哈是的,这是个错别字。谢谢。我不是在这里重新发明URL结构 
完全没有
4 个赞
Julian2
(Julian R)
5
嘿 @chapoi!很高兴我找到了这个组件。我已经把它添加到我们的论坛了,谢谢!我甚至可能会切换到“多链接”版本。
快速说明:在“个人资料自定义链接图标”字段下方的描述文本中,有一个多余的“the”
我必须为此添加一个组件,而不是为用户字段添加另一种字段类型,这有什么特别的原因吗?
干杯!
2 个赞
我不确定我是否理解这个问题。用户字段并非全部自动显示在个人资料或用户卡片上。
2 个赞
Julian2
(Julian R)
8
嘿 Charlie,
抱歉之前没有说清楚。如果有一个用户字段的字段类型,允许链接而不是纯文本,那就太好了。
或者,我们正在错误地使用用户字段?以下是我们目前的使用方式:
链接必须复制粘贴,而不是直接可点击。
1 个赞
好的,现在我明白了,谢谢!
是的,你提出的观点确实很合理。我会研究一下你建议的可能性;我猜想这背后 一定 有原因没有这样做,但我目前还不知道。
2 个赞
chapoi
11
所以,我看了一下,但必要的更改远远超出了我的设计师技能(请阅读:后端数据库相关的东西)——所以我恐怕必须使用该插件。
您可以考虑的一个选项是提出一个功能请求,看看它是否能引起更多兴趣。
干杯!
2 个赞
这个解决方案很棒,我希望我们能帮助改进它。我们的个人资料链接的格式为“https://www.domain.com/user/[USER-ID]/”。末尾的斜杠破坏了我们的解决方案。我可以添加一个 URL 重写,但更好的解决方案是使代码更具适应性。我想要可以正常工作的返回站点的真实链接!
我尝试将插件转换为主题,以便改进 JavaScript,但那个 CONVERT Discourse 函数似乎不起作用。
你能进行更新以添加功能吗?
import Component from “@glimmer/component”;
import { tracked } from “@glimmer/tracking”;
import { service } from “@ember/service”;
export default class ProfileCustomLink extends Component {
@service site;
@tracked customLinkUrl;
@tracked customLinkFieldId;
@tracked showCustomLink = false;
@tracked user = this.args.model.username;
@tracked userFields = this.args.model.user_fields;
constructor() {
super(...arguments);
if (settings.profile_custom_link_field) {
const siteUserFields = this.site.user_fields;
if (!siteUserFields) {
return;
}
const customLinkField = siteUserFields.filterBy(
“name”,
settings.profile_custom_link_field
)[0];
if (!customLinkField) {
return;
}
this.customLinkFieldId = this.userFields[customLinkField.id];
if (!this.customLinkFieldId) {
return;
} else {
this.showCustomLink = true;
if (settings.profile_custom_link_prefix.includes(“[CUSTOM-LINK-FIELD-ID]”)) {
const url = settings.profile_custom_link_prefix.replace(“[CUSTOM-LINK-FIELD-ID]”, this.customLinkFieldId);
this.customLinkUrl = url;
} else {
const url = settings.profile_custom_link_prefix + this.customLinkFieldId;
this.customLinkUrl = url;
}
}
} else {
const url = settings.profile_custom_link_prefix + this.user;
this.customLinkUrl = url;
this.showCustomLink = true;
}
}
}
@Julian2 我刚刚在这里发布了一个功能请求,没有看到你关于这个话题的帖子
2 个赞