أستخدم حاليًا الأداة المصغرة التالية لعرض لافتة/رابط بعد المنشور الأول للموضوع. هذا يعمل بشكل جيد حتى الآن:
<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
12 يناير 2024، 8:17ص
2
OrkoGrayskull:
بعد المنشور الأول
OrkoGrayskull:
الموضع الذي حددته في الصورة هو بعد جميع منشورات الموضوع. لذلك، عندما تكون هناك ردود، ستكون اللافتة الخاصة بك أسفل هذه الردود وليس مباشرة أسفل المنشور الأول.
إعجابَين (2)
piffy
12 يناير 2024، 8:17ص
3
يوجد منفذ إضافي هناك يسمى topic-above-footer-buttons
يساعدك هذا في رؤيتها:
(deprecated) Plugin outlet locations theme component
ثم اتبع هذا الدليل:
Discourse includes hundreds of Plugin Outlets which can be used to inject new content or replace existing contend in the Discourse UI. ‘Outlet arguments’ are made available so that content can be customized based on the context.
Choosing an outlet
To find the name of a plugin outlet, search Discourse core for “<PluginOutlet”, or use the plugin outlet locations theme component. (e.g. topic-above-posts).
Wrapper outlets
Some outlets in core look like <PluginOutlet @name="foo" />. These allow you…
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)
تم إغلاقه في
18 فبراير 2024، 6:56ص
6
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.