Category Banners

No… Discourse doesn’t store descriptions for tags, only categories, so it wouldn’t be possible with this component.

It would be possible to modify the tag banner component to add descriptions in a theme setting… but if you plan on having more than a couple dozen tags it would start to become unwieldy, so it’s not a great option.

The best path would be to create a plugin that adds a description functionality to tags… though that would be significantly more complex.

2 Likes

Doesn’t this component pull text from the 1st paragraph of the 1st post in the category if its not set in the category’s settings? The default ‘about’ one. Thats always how i use it.

What about a plugin which auto-creates a default ‘about’ page for each tag-page. Would it be a possible, or a good path to go down, to create that and then point your plugin at that post if its set to work on tag-pages?

Yes, but Discourse pulls that text out of the post and I sets it as the category description… so most of the work is already done, I just reused it here.

It might be possible to get the oldest topic with a specific tag and use that as the description so the functionality is similar? I’ll have to look into it some more.

3 Likes

Am I stoopid… or is there no way to submit an issue to the Git repo:

??

1 Like

You do that by posting here with details :slight_smile:

3 Likes

Has this request been resolved by this or any other theme component or method? I am looking for this functionality to give context to users landing on pages of a specific category i.e. through web searches or links shared in social media, and not going through the category main page.

I have two Discourse-hosted sites where I’ve replaced (via discourse category icons component) the default padlock-icon to be a Font Awesome icon. But, the padlock is still showing in the category banners—not just the one category I’ve shown from each of these sites, but for all of the categories where the icon should appear, I’m still seeing the default padlock-icon.

1 Like

I find a conflict between this and the latest version of Discourse ( 2.9.0.beta3) which occurs when you add an image a category or subcategory.

The plugin pulls the 1st line of text from the ‘about’ post into the banner. When you add an image to a category the latest versions of Discourse pulls the same text into its own header next to the image.

The issue this creates is that every category and sub category has to have an image and the setting ‘show description’ is turned off, or none can have an image as this leads to the description being repeated in the banner and underneath it. So its all or nothing.

I’m not really sure this is actually an issue with this plugin, or if i’m missing a way to turn off the image and description inside the category in Discourse so it doesn’t mess up my Category banners.

1 Like

I was able to solve the issue by using a different plugin: Discourse Category Header theme component

The final result doesn’t look as good as this one unfortunately. I wonder if the options for the other plugin can just be copy/pasted into this one, as the only obvious difference is whether the plugin is targeting the banner or header div. This one has better styling, that one as the ability to turn more options on and off and customise.

1 Like

What could I add in a custom CSS to reduce the line space between the Category and the Description text?

1 Like
div[class^="category-title-header"] .category-title-contents .category-title {
    margin-bottom: 0;
}
2 Likes

Perfect! thankyou for that :pray:

2 Likes

Would it be an idea to make these banners clickable? Because now the banner only includes the first line of the “About” topic of a category. Often there is more information in such an “About” topic. By making them clickable it becomes easier to learn more than just that first line. Of course people can create links to the “About” topic as well. But while being in that topic already, you then have a link to itself. That looks like an ugly hack. Just a suggestion :slight_smile:

2 Likes

I’ve just made an update to this component that makes it integrate with Tag Banners

When both components are installed and you’re filtered to a category and a tag, rather than stacking the banners, now the tag name will be shown within the category banner:

8 Likes

Thanks Kris, another great integration!

Few issues though:

  • it’s not working for me in mobile view (even on desktop browser—no web console errors)
    • category banner displays properly in both desktop and mobile view, but tag banner only displays in desktop view
  • when also using with Tag icons component
    • tags have generic tag icon and the icon defined by Tag icons (it would be better if only Tag icons defined icon was displayed in such cases)
    • when icon defined by Tag icons is the same color as Category banner the icon is rendered invisible (similar problem as Category banners + Category icons integration—if possible please allow the Tag icon to match the banner text color for this combo too)
    • Remove hyphens / underscores from Tag banners completely hides the icon defined in Tag icons
2 Likes

Thanks for the quick feedback!

I’ve added a fix for the tag not appearing in mobile view:

I’ve also added a setting to disable the tag icon for now, which is a temporary solution for working better with the tag icons component. I’ll have to spend a little more time getting a proper integration with the tag icons component working.

3 Likes

Thanks for a quick workaround, meanwhile I’ve got another one for you :wink::

when using Category banners together with Tag banners with Remove hyphens / underscores set to true, the tag name (eg. with-hyphens is displayed without hyphens under the title and hyperlinked but the link is invalid (/tag/with hyphens) and results in 404.

2 Likes

Oh another good one, thanks again!

This fix relies on a minor Discourse update: DEV: add optional `displayName` parameter for `discourse-tag` by awesomerobot · Pull Request #21391 · discourse/discourse · GitHub

So once Discourse and the component are updated, tags without hyphens or underscores will be linked correctly.

2 Likes

I’ve successfully added banners to some of my categories but can’t add them to others.

The categories it doesn’t work for have names like “Weather - General”, i.e. Space-Hyphen-Space in the middle of the name. If I change the name to “Weather-General”, i.e. no spaces around the hyphen the banner is displayed as expected. In both cases the slug for the category is the same - “weather-general” so I’m not sure why that’s not accepted as a valid value in one case but is in the other.

1 Like

15 posts were split to a new topic: Can I align the category banner away from the sidebar?