Mostrare logo header diverso in base alla categoria?

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

Ho recentemente avuto lo stesso problema. Mi rendo conto che questo è un argomento vecchio, ma ecco una soluzione nel caso qualcuno si imbatta in essa.

Puoi usare CSS e sfruttare le classi sull’elemento body per rilevare in quale categoria ti trovi.

// Non mostrare il logo del sito normale
body.category-something #site-logo {
    display: none;
}

// Mostra un'altra immagine nel titolo
body.category-something .home-logo-wrapper-outlet {
    height: 50px;
    width: 100px;
    background-image: url($category-something-image);
}

Spero abbia senso :slight_smile:

Penso che dovresti mettere la tua immagine sull’elemento <a>, altrimenti il link del logo semplicemente collasserà.

// Mostra un'altra immagine nel titolo
body.category-something .d-header .title a {
  ...
}

Ah, giusto, mi stavo concentrando principalmente sui selettori CSS. Grazie per avermelo fatto notare.

1 Mi Piace