مكوّن تصميم الموضوع: نص نائب للموضوع

نص قالب الموضوع كنص نائبي (مكون السمة)

يتيح لك هذا المكون للسمة عرض قوالب الموضوعات كنصوص نائبة (علامات مائية) بدلاً من نصوص القالب القابلة للتحرير.

يتيح لك ذلك توفير تعليمات مخصصة كنص نائب لكل موضوع.

على سبيل المثال:

هذا هو النص النائب (العلامة المائية) العادي.

ملاحظة: يمكنك بالفعل تغيير هذا على مستوى الموقع عن طريق تغيير النص المخصص.

انتقل إلى لوحة الإدارة >> تخصيص >> نص

ثم ابحث عن النص الذي تراه هناك على الشاشة.
يجب أن يعطيك البحث عن “BBCode” ما تريد:

ثم غيّر القيم الخاصة بـ js.composer.reply_placeholder إلى نص النائب الذي تريد عرضه.

يمكنك أيضًا تعيين قالب موضوع في كل فئة.

في مربع حوار “تحرير الفئة”، حدد “قوالب الموضوع”. يمكنك إضافة قالب مخصص لفئتك.

يعمل هذا بشكل جيد، ولكن يجب على المستخدم حذف نص القالب قبل أن يبدأ في كتابة منشوره.

يتيح لك هذا المكون للسمة عرض نص قالب الموضوع كنص نائب (علامة مائية) بدلاً من النص القابل للتحرير. ببساطة انقر على المربع وابدأ الكتابة.

يمكن ضبطه لعرض جميع قوالب الموضوعات كنصوص نائبة، أو يمكنك فعل ذلك على أساس كل حالة على حدة عن طريق إضافة مؤشر [placeholder] إلى قالب الموضوع.

تثبيت مكون السمة

:hammer_and_wrench: مستودع Git: https://github.com/naidihr/discourse-topic-template-placeholders

:thinking: كيف أقوم بتثبيت سمة أو مكون سمة؟

الائتمان

شكرًا لـ @merefield على إعادة هيكلة عنصر JQuery لاستخدام إطار عمل Ember ونواة Discourse.

يرجى ملاحظة أن النسخة المحدثة تم اختبارها لتعمل فقط على إصدارات 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:

(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 https://github.com/naidihr/discourse-topic-template-placeholders/pull/3

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: