dfuentes
(Daniel Fuentes)
2020 年 9 月 1 日午後 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)
2020 年 9 月 1 日午後 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)
2024 年 9 月 1 日午後 7:38
4
「いいね!」 4
もし自分でやる時間があれば、ここにコードを貼り付けます。それか、誰かが先に時間があれば、とても感謝します…
「いいね!」 1
manuel
(Manuel Kostka)
2025 年 1 月 27 日午後 11:19
7
テーマのためにこれを行いました。サイトのタイトルと短い説明を使用していますが、テーマ設定やローカライズされたテキストの値も挿入できます。
components/header-logo-title.gjs に Glimmer コンポーネントを追加します。
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
(v.1.26.0以降)api.renderAfterWrapperOutlet("home-logo")も使用できます。これは、__before/__afterというマジックワードを指定せずに、実際のコンセント名を使用する利点があります。
「いいね!」 4
manuel
(Manuel Kostka)
2025 年 1 月 27 日午後 11:43
9
@Arkshineさん 、ありがとうございます。より良いものになりました。前の投稿を更新しました。
「いいね!」 3
現在これを試していますが、問題が発生しています。「components/header-logo-title.gjs」の「glimmerコンポーネント」にアクセスするにはどうすればよいですか?
私のコミュニティはこちらです:https://community.worldradioleague.com/
有料プランを利用しています。もしかしたら、これを確認するためにDiscourseコアへのアクセスがないのでしょうか?
manuel
(Manuel Kostka)
2025 年 3 月 20 日午後 9:04
11
「いいね!」 3