dfuentes
(Daniel Fuentes)
1 سبتمبر 2020، 3:19م
1
I’m new to discourse, so I apologize if this is something that is easily done, however, I can’t seem to find where I can define the text that I want to appear beside our logo in the header of our discourse page.
Within the red box in the header is where I’d ideally like to add text saying ‘Community Forums’ or something of the sort:
How can I go about getting this done?
Thanks in advance for any and all feedback!
Johani
(Joe)
1 سبتمبر 2020، 4:10م
2
Hey Daniel
You can use something like this to add text next to the header logo on your site
<script type="text/discourse-plugin" version="0.8">
api.decorateWidget("home-logo:after", helper => {
const titleVisible = helper.attrs.minimized;
const headerText = "Text you want to add"; // <--- change this text
if (!titleVisible) {
return api.h("span.header-text", headerText);
}
});
</script>
You’d add it in the header section of your theme / component. You can read more about the Discourse theme system here
This is a crash course in Discourse theme basics. The target audience is everyone who is not familiar with Discourse themes. If you’ve already used Discourse theme / theme components, this guide is probably not something you need to read.
What are themes and theme components?
A theme or theme component is a set of files packaged together designed to either modify Discourse visually or to add new features.
Let’s start with themes.
Themes
In general, themes are not supposed to be compatible …
3 إعجابات
يؤدي هذا الآن إلى ظهور لافتة خطأ، بسبب التغييرات التي طرأت على Discourse. هل لديك أي اقتراحات لتحقيق نفس النتيجة بالنهج الجديد؟ شكراً.
Lilly
(Lillian Louis)
1 سبتمبر 2024، 7:38م
4
4 إعجابات
إذا كان لدي وقت للقيام بذلك بنفسي، فسأقوم بلصق الكود هنا. بدلاً من ذلك، إذا كان لدى شخص ما وقت أولاً، فسأكون ممتنًا جدًا…
إعجاب واحد (1)
manuel
(Manuel Kostka)
27 يناير 2025، 11:19م
7
لقد قمت بهذا للتو لسمة. أنا أستخدم عنوان الموقع ووصفه المختصر، ولكن يمكنك أيضًا إدراج قيم من إعدادات السمة أو نص مترجم.
أضف مكون glimmer في components/header-logo-title.gjs
import Component from "@glimmer/component";
import { service } from "@ember/service";
export default class HeaderLogoTitle extends Component {
@service siteSettings;
<template>
{{#unless @outletArgs.minimized}}
<div class="header-logo-title">
<span
class="header-logo-title__title"
>{{this.siteSettings.title}}</span>
{{#if this.siteSettings.short_site_description}}
<span
class="header-logo-title__description"
>{{this.siteSettings.short_site_description}}</span>
{{/if}}
</div>
{{/unless}}
</template>
}
قم بإرفاقه بالمنفذ في /api-initializers/my-theme.js
import { apiInitializer } from "discourse/lib/api";
import HeaderLogoTitle from "../components/header-logo-title";
export default apiInitializer("1.26.0", (api) => {
api.renderAfterWrapperOutlet("home-logo", HeaderLogoTitle);
});
يتحقق المساعد #unless من حالة التصغير للشعار ويضيف النص فقط عندما يكون الشعار الكامل مرئيًا. إذا كنت تريد دائمًا إظهاره، فستحتاج إلى إسقاط هذا الشرط.
4 إعجابات
يمكنك أيضًا استخدام api.renderAfterWrapperOutlet("home-logo") (منذ الإصدار 1.26.0). يتميز بميزة استخدام اسم المنفذ الفعلي دون توفير __before/__after السحري.
4 إعجابات
manuel
(Manuel Kostka)
27 يناير 2025، 11:43م
9
شكرا لك @Arkshine . هذا أفضل، لقد قمت بتحديث المنشور السابق.
3 إعجابات
أحاول القيام بذلك الآن ولكن أواجه بعض المشاكل - كيف يمكنني الوصول إلى “مكون اللمعان في components/header-logo-title.gjs”؟
مجتمعي هنا: https://community.worldradioleague.com/ .
أنا على الخطة المدفوعة - ربما ليس لدي وصول إلى نواة Discourse لرؤية هذا؟
manuel
(Manuel Kostka)
20 مارس 2025، 9:04م
11
لقد قمت بتغليف هذا في مكون، يمكنك محاولة استخدامه: Manuel Kostka / Discourse / Helpers / Header Logo Title · GitLab . يضيف عنوان الموقع ووصف الموقع المختصر افتراضيًا. بدلاً من ذلك، يمكنك إضافة نص مخصص للعنوان والوصف في إعدادات المكون.
3 إعجابات