토픽 템플릿 플레이스홀더 텍스트 테마 컴포넌트

토픽 템플릿 플레이스홀더 텍스트 테마 컴포넌트

이 테마 컴포넌트를 사용하면 토픽 템플릿을 편집 가능한 템플릿 텍스트가 아닌 플레이스홀더(워터마크)로 표시할 수 있습니다.

이를 통해 각 토픽에 대해 사용자 지시사항을 플레이스홀더로 제공할 수 있습니다.

예를 들어:

이것은 일반적인 플레이스홀더(워터마크) 텍스트입니다.

참고: 커스텀 텍스트를 변경하여 사이트 전체에서 이미 이 값을 변경할 수 있습니다.

관리 >> 사용자 지정 >> 텍스트 로 이동하세요.

그런 다음 화면에서 보는 텍스트를 검색하세요.
“BBCode”를 검색하면 원하는 항목을 찾을 수 있습니다:

그런 다음 js.composer.reply_placeholder 값을 표시할 플레이스홀더 텍스트로 변경하세요

또한 각 카테고리에서 토픽 템플릿을 설정할 수도 있습니다.

카테고리 편집 대화상자에서 토픽 템플릿을 선택하세요. 카테고리에 대한 사용자 지정 템플릿을 추가할 수 있습니다.

이것은 잘 작동하지만, 사용자는 게시물을 작성하기 시작하기 전에 템플릿 텍스트를 삭제해야 합니다.

이 테마 컴포넌트는 편집 가능한 텍스트 대신 토픽 템플릿 텍스트를 플레이스홀더(워터마크) 텍스트로 표시할 수 있게 해줍니다. 단순히 상자를 클릭하고 타이핑을 시작하면 됩니다.

모든 토픽 템플릿을 플레이스홀더로 표시하도록 설정하거나, 토픽 템플릿에 [placeholder] 표시기를 추가하여 개별적으로 처리할 수도 있습니다.

테마 컴포넌트 설치

:hammer_and_wrench: Git 저장소: https://github.com/naidihr/discourse-topic-template-placeholders

:thinking: 테마 또는 테마 컴포넌트를 설치하는 방법?

크레딧

JQuery 요소를 Ember 프레임워크와 Discourse 코어를 사용하도록 리팩토링해 주신 @merefield님께 감사드립니다.

업데이트된 버전은 Discourse 2.4.1 버전 이상에서만 작동하도록 테스트되었습니다. 이전 버전의 Discourse를 사용하고 계신다면, 2.3.10 버전에서 테스트된 원래 버전을 시도해 보시기 바랍니다.

원래 버전 저장소: https://github.com/naidihr/discourse-topic-template-placeholders_original

35개의 좋아요

PS development note. I had to do a JQuery hack to get this to work as a theme component. If it is possible to update the placeholder via the model - I would be grateful of you would let me know.

8개의 좋아요

You can try something like this

<script type="text/discourse-plugin" version="0.8">
  api.modifyClass("model:composer", {
    applyTopicTemplate() {
      this._super(...arguments);

      Ember.run.schedule("afterRender", () => {
        // do your work here
      });
    }
  });
</script>

This should allow you to add some custom logic when Discourse applies category topic templates.

That said, this type of way of writing stuff is a bit outdated. I would also recommend that you give this a read if you plan to spend a lot time on Discourse themes. It makes life much easier.

9개의 좋아요

Great idea for a Theme Component!

I’ve gone ahead and submitted a PR to do the following:

  • removes need for jQuery
  • removes need to worry about timing (use Ember framework & Discourse core, don’t fight them)
  • modifies the Composer Model to help achieve the result (as you rightly suggested)

I won’t be upset if you don’t merge it, but hope it helps to see another way of doing things :slight_smile:
https://github.com/naidihr/discourse-topic-template-placeholders/pull/1

(I can’t promise there are no bugs, but happy to follow up on any ! :cowboy_hat_face: )

9개의 좋아요

Thanks Robert. I’ve merged that PR. Much appreciated :+1:

2개의 좋아요

This is literally what I was looking for! You are a god! :bowing_man: :shallow_pan_of_food: :bowing_woman:
Please accept this humble emoji offering. :canned_food:

1개의 좋아요

FYI this only works if you first go to the category and create a new topic. If you try to create a new topic from the latest page and then select a category from the dropdown the text doesn’t display.

2개의 좋아요

That’s expected? That’s how Topic Template functionality normally works. The Topic Template won’t be considered in the latter case.

But yeah, imho, that could be improved in even vanilla Discourse without this TC to support your latter case. I have personally found it annoying that users are not presented with the Template if they go the second route.

This TC is just piggybacking off of core so …

Maybe we’re talking about different things, but this is how it works for me…

1개의 좋아요

This might be due to some other reason because it works here on Meta. if you go to /latest, open the composer and then select the marketplace category you get the template we have for that.

4개의 좋아요

Yep weird. Sorry I think it might have been resolved. This was nagging me for ages but seems to work now.

Ok that presents a new challenge. Haha.

4개의 좋아요

Hi Robert - I tested it after the merge and it was working - but it no longer is for me? This is with the override setting - not using the [placeholder]. Please can you check with your build as well?

Also on my original version - it did work the same if you started a new Topic from the latest page and then select the category.

I may need to roll back…?

I’m looking at it now. Give me a little while.

OK PR for fix raised: FIX: change the placeholder & template when switching selected Category by merefield · Pull Request #2 · naidihr/discourse-topic-template-placeholders · GitHub

It is now taking the Category from the Composer selection. Now that’s done, it seems to work in all situations, but please confirm.

2개의 좋아요

Hi Robert, I merged that last PR and updated to the latest theme component version in but it is still showing the template text for default by me, even though I have “display all topic templates as placeholders” set. I am on Discourse 2.4.1. Any more thoughts?

2개의 좋아요

That works, but it also doesn’t work at all if display all topic templates as placeholders is turned on, even if I’m in the category. Regretting volunteering for this now? :stuck_out_tongue_winking_eye:

2개의 좋아요

No problem guys. We just iterate. :). I’ll take a look.

Update: PR FIX: resolve issue with displaying all Topic Templates as Placeholders by merefield · Pull Request #3 · naidihr/discourse-topic-template-placeholders · GitHub

When checking out remember to refresh the page if you change a setting.

2개의 좋아요

Great Robert. That last PR has fixed it. Also when starting a topic from the latest or category pages. All looking good now. Thank you for taking the time to look at this. Very neat solution _super job :wink::+1:

3개의 좋아요

No problem. A pleasure. Sorry my initial testing should have been more thorough. Thanks for your patience.

I think we are on a good track right now, hopefully!

Keep coming up with more great ideas and putting them into practice!

3개의 좋아요

Howdy folks! We love the idea of this theme component!

I just tried to install it on our discourse instance but I’m running into some trouble here.
It seems that when enabled on the theme, it breaks some of the styling already in the theme.
For example, the buttons at the user drop down:

become like this when enabled:


In addition to this, the placeholder doesn’t appear to work, both with 'Display all your Topic Templates as placeholders (watermark text)' enabled, and disabled.

It could be that our discourse instance is v2.3.10?

I’ve taken a look at the code here and can’t discern why our styling would be messy.

We rely on another team to manage and update our discourse instance & it’s a bit of a big task to get that done.

I’m hoping for a quick tip to potentially fix this, but, if it boils down to our discourse version that’s fine too!

Thanks in advance :smiley: