I’d like to have a different style on our homepage (which is /latest) then on /new, /unread etc. Is this possible via CSS at the moment? Thanks!
AI-generated summary
In a support discussion titled ‘Address /latest differently then /new etc via CSS,’ Krischan asked if it’s possible to apply different CSS styles to the homepage (/latest) versus other filters like /new or /unread. Johani explained that no filter-specific classes are currently added by default and asked for more context. Krischan clarified they’re using the topic list preview plugin and want teaser images to appear only on the homepage (https://1e9.community/). Johani provided a JavaScript solution to inject dynamic body classes like filter-mode-latest, filter-mode-new, etc., based on the active filter. These can be combined with .navigation-topics for targeted CSS rules. Johani also cautioned that hiding images via CSS won’t reduce bandwidth usage since images will still be downloaded. The post ended with Krischan thanking Johani for the helpful solution.
We don’t add any classes based on the current filter. What are you trying to do?
We use the topic list preview plugin to show teaser images and would like to have them on the homepage only: https://1e9.community/
You can add this to the header tab of your theme and it will add the classes to the <body> tag as you navigate
<script type="text/discourse-plugin" version="0.8">
api.modifyClass("component:d-navigation", {
didInsertElement() {
document.body.classList.add(`filter-mode-${this.filterType}`);
},
willDestroyElement() {
document.body.classList.remove(`filter-mode-${this.filterType}`);
}
});
</script>
It will add filter-mode-FILTERMODE as a class like so
filter-mode-top
filter-mode-new
filter-mode-latest
You can then combine that with the navigation-topics class to make your CSS specific like so
.navigation-topics.filter-mode-new {
// do stuff
}
Do note that using CSS to hide images will not prevent the browser from downloading them. You won’t get any bandwidth savings from this, only visual changes.
Also, nice site ![]()
Thanks so much! Great help!