Topic Template Placeholder Text 主题组件

Thanks guys, after updating and a hard refresh it is now working as expected!

2 个赞

Just started testing this component; thanks! I’d curious about adding Placeholder text to private messages. Has anyone tried that?

Private messages have the same default placeholder text as Topic posts. It can be changed by the site administrators under the admin settings Customize > Text. Search for js.composer.reply_placeholder - as shown at the top of this thread.

If you use this component to customise the placeholder text for each Topic Category, the default placeholder text should only apply to the Private Messages.

1 个赞

This theme component is really cool. I’ve been trying to find a way to give my users a little more guidance when they create a topic, and would like to make the experience more like completing a form.

Right now, this theme component makes it so that all text that is preloaded in a topic is a single placeholder. So, once a user types anything in the topic composer, all of the placeholder text goes away.

Would it be possible to have it so that there are different placeholders on the page? For example, the topic template could load a separate placeholder for:

“Name”


“Location”


“Issue”

So that when the users types in their name, the other placeholders for Location and Issue stay there, until the user types in their spots too?

The default Discourse Topic Template Text stays whilst the user is typing. It sounds like that is what you need?

The Placeholder Approach:

What I (and others?) would be looking for would behave more like placeholders in a form (meaning with separate form elements).

The basic default behavior now would allow me to list out different sections of the form, like what I wrote (“name”, “location”, and “issue”), but the default template behavior has the same problems as noted before–markdown makes it confusing and user can break it easily.

I think the ideal would be like a normal form, where there is a placeholder for each section (name, location, and issue), but (here’s the difference) the sections would behave independently. So when the user clicks on the name section, the placeholder “name” disappears, but the other sections stay until the user clicks on those too.

I could imagine this being possible (?) with jquery. Each section would have to have its own div with id, and then jquery would allow showing or removing the text of that particular id when the user clicks on it. This would require adding divs into the textarea, however, and I’m not sure how to do that.

I’m investigating that here.

The Template Approach

Probably an alternative would be that the section headers don’t “disappear” when the user clicks. So the section headers (example: Name, Location, and Issue) would be text that would stay on the page. To make it more form-like, compared to the current template default:

  1. The section header text could not be edited by the user (ie, contenteditable="false")
  2. The section break points could not be removed by the user
  3. There would be space below the section header where it’s clear the user can type. In the current default template, they’d have to go to where the text is, hit return, to create space to type.

Perhaps this is the easier way to do it?

I found this setting only apply on first post not working.
It doesn’t work if I want all posts in a topic have the same placeholder and deactivate the setting. I get a standard placeholder in this case.

Any possibility of having a placeholder specific to replies (not the first post in a topic)? I’m hoping to give users more guidance on what can be in a reply, and a placeholder that pops up in a reply would be helpful.

4 个赞

我发现只有当占位符文本有多行时,它才对回复 有效。我不知道为什么,因为代码对我来说有点太复杂了。

附注

在此期间,我提交了一个小的拉取请求(PR),以停止浏览器控制台的警告:

2 个赞

已合并,谢谢你 Nathan。

2 个赞

我遇到了一个问题,占位符文本没有显示。我错过了什么?

模板:

组件设置

没有占位符/模板文本显示

取消勾选“将所有主题模板显示为占位符”时

模板显示为可编辑文本(非占位符文本)

编辑模板文本,其中包含 [placeholder]

模板文本消失/没有占位符文本

这是在一个全新的 Discourse 安装上,没有安装插件/组件 - Discourse 3.4.0

是的,这个主题组件似乎停止工作了。:thinking:

3 个赞

这个组件不工作了。

好吧,我可以确认它不能工作。可能是由于 Discourse 最近的重大更改导致的。

1 个赞

你好,有希望更新吗?:face_with_tongue:

你好 :waving_hand:

我已经创建了一个 PR,让这个主题组件重新焕发生机,并使其与最新的 Discourse 兼容。 :slightly_smiling_face:

5 个赞

感谢 @Don,我已合并你的拉取请求。请测试是否对你有用。:folded_hands:

2 个赞