Discourse Category Headers theme component

I see a lot of error messages in Console mentioning this component.

Deprecation notice: use injected siteSettings instead of Discourse.SiteSettings (deprecated since Discourse 2.8) (removal in Discourse 2.9)

We fixed this in another plugin by changing Discourse.application.SiteSettings[...] to container.lookup('site-settings:main')[...]

Perhaps that would solve the issues here too.

2 Likes

It doesn’t work for me, I already tried all the ways, changing the configuration of how the categories are displayed, I even went back to the “Default” theme of Discourse and I still can’t get it to work.

2 Likes

I just updated from 2.9.0.beta8 to 2.9.0.beta9 and I’m facing the same problem. Just doesn’t seem to work for some reason

2 Likes

And on github it hasn’t been updated in 2 years, @Rhidian is this component no longer supported?

2 Likes

I’ll have a look when I can. It’s only being updated if a Discourse update breaks it. Happy to take pull requests on GitHub if anyone has chance to look before I do.

4 Likes

This stands out to me straight away. Not sure yet why beta9 in particular has triggered the failure though.

Comparing my instances, there was no issues for this version

And the earliest version I have a problem with is this commit

So a commit between July 28th and August 25 appears to have upset something

2 Likes

I took a quick look at this to see whether it was a core issue which caused the breakage.

It looks to me like there is some invalid javascript in the component. Given that it worked in the past, I suppose our recent updates to the Theme JavaScript Babel transpiling configuration have made it less forgiving of these kinds of errors.

I opened a PR to fix here: FIX: Do not access variables before initialization by davidtaylorhq · Pull Request #3 · naidihr/discourse-category-headers · GitHub

And another which will clean up the Discourse.SiteSettings warning: Remove use of deprecated and private functions/properties by davidtaylorhq · Pull Request #4 · naidihr/discourse-category-headers · GitHub

5 Likes

That’s brilliant David. Thank you so much. I’ve merged those in.

Rhod and Tristan - does that fix the issue for you now?

4 Likes

Yes, thank you very much to you and @david , now I am checking it from my mobile device, later I will check it on PC, but it seems to be working correctly.

1 Like

Like a dream! Thanks Rhidian!

2 Likes

Thank u for this awesome component!

Is there a way to add a title to the differents tag pages also?

How do I let the banner appear only on the homepage and let level 4 truste members edit it too?

I would like to use this for exactly one category. I could list everything else in the “Hide category exceptions”, but that seems difficult to maintain. Would it be possible to add a setting that is the inverse of that?

1 Like

I love this theme, but there is a bug that I don’t know how to fix, it’s because of my ignorance.
I use this component to put banners in the subcategories, but in the subcategories that I do not use the image is a gap that is not nice. example:
Captura de pantalla 2023-09-12 000632

Hi @Pandabear I went to your forum to see if I could help, but the banner doesn’t seem to be enabled. Perhaps once you enable it, try this:

in common-css of a theme or theme component:

.category-parentcategory-subcategory {
  .category-title-contents {
    display: none;
  }
}

The parentcategory and subcategory are are the respective category and subcategory slug name (the lower case name you see in the browser URL field). for example, in the case of your screenshot the URL is https://holaforo.com/c/musica/thalia/ so the code would be

.category-musica-thalia {
  .category-title-contents {
    display: none;
  }
}

Thank you very much, you are being very kind. I had disabled it because I couldn’t find a way to fix it.

I’ve turned it back on for now I’ve only put a banner in the following subcategory

in the rest of the subcategories I don’t have a photo at the moment, but some subcategories I’m not going to put a photo and it looks ugly with a gap.

Concerning the following code:

.category-parentcategory-subcategory {
  .category-title-contents {
    display: none;
  }
}

Do I have to do it for all categories and subcategories that I am not going to put photo?

I am doing it for all categories and subcategories and it does work this way:

.category-musica-thalia {
  .category-title-contents {
    display: none;
  }
}
.category-musica {
  .category-title-contents {
    display: none;
  }
}
.category-musica-musicapop1 {
  .category-title-contents {
    display: none;
  }
}
.category-musica-musicavariada {
  .category-title-contents {
    display: none;
  }
}

1 Like

@Pandabear - I am confused as to why you are not using the hide category exceptions setting in this theme component?

Anyways, if necessary, you can also do something like this so that it is easier to manage which categories and subcategories you want to apply the css code to:

$categories: 'musica', 'musica-thalia', 'musica-musicapop1', 'musica-musicavariada';

@each $category in $categories {
    .category-#{$category}  {
      .category-title-contents {
          display: none;
      }
   }
}
1 Like

Thank you for all your help.
I did it with all categories with css except “soporte”.

the category “soporte” I have it set with hide, but it still shows a gap.

Hi, i’m getting these warnings about this component:

[THEME 68 ‘Category Headers theme component’] Deprecation notice: controller:navigation/category no longer exists, and this shim will eventually be removed. To fetch information about the current discovery route, use the discovery service instead. [deprecation id: discourse.navigation-category-controller]

1 Like

I made a PR :+1:

3 Likes