カテゴリ別にヘッダーロゴを表示しますか?

Is there a way to show a different main logo in the header (top left) when browsing threads within a certain category or their sub categories? Thank you.

I believe the body includes a class category-{category here}, which you could use to change category specific CSS.

I don’t know how to execute a script after the page content have loaded (I’m interested to know that too!), but for changing the logo image, you could do this:

// in a condition like if category == "somecategory" then…
document.getElementById("#site-logo").src = settings.theme_uploads.logo_cat1;

where logo_cat1 is the variable name of a custom logo:
image

私も最近同じ問題が発生しました。古いトピックであることは承知していますが、誰かが後で見つけた場合に備えて、解決策を以下に示します。

CSSを使用して、body要素のクラスを活用して、どのカテゴリにいるかを検出できます。

// 通常のサイトロゴを表示しない
body.category-something #site-logo {
    display: none;
}

// タイトルに別の画像を表示する
body.category-something .home-logo-wrapper-outlet {
    height: 50px;
    width: 100px;
    background-image: url($category-something-image);
}

これで意味が通じるといいのですが :slight_smile:

ロゴリンクが折りたたまれるのを防ぐには、画像を <a> 要素内に配置する必要があると思います。

// タイトルに別の画像を表示する
body.category-something .d-header .title a {
 ...
}

ああ、そうですね。主にCSSセレクターに焦点を当てていました。訂正していただきありがとうございます。

「いいね!」 1