šŸ—ƒ Category List Widget

The Category List Widget lets you display a list of categories in a sidebar. It is typically used as a navigation menu.

Follow this guide to install and administer this widget: https://discourse.pluginmanager.org/t/installation-and-setup

Parents and subcategories

The widget will show parent categories and subcategories in a hierarchy. Clicking on a parent will display a list of subcategories if the parent has any subcategories. If the parent doesnā€™t have any subcategories clicking on it will navigate to that category.

Settings

Excluded categories

You can exclude categories from the list by adding their category ā€œslugsā€ to the excluded categories setting in the theme component settings. You can find the category slug in the categoryā€™s settings (itā€™s also in the category url).

Order by activity (advanced)

The default order is the order the categories appear on the /categories page. You can change this order using the admin controls on the categories page.

The order by activity setting orders sub-categories by activity in that category (latest post created in the category), however this relies on additional data being sent from the server to the client, which we currently do in another plugin. The upshot of this is this wonā€™t work out of the box. You need to have a plugin installed that includes this:

add_to_serializer(:site_category, :latest_post_created_at) { object.latest_post&.created_at }

Unless this makes sense to you, do not use this setting. We will be adding additional order settings in the future.

Show latest

If a category slug is included in this setting the category and any sub-categories will display their ā€œlatestā€ count.

Collapsible sidebar

Adds a nice Minimise button and arrow which collapses down the widget nicely. This is automatic when the available width is constrained.

image

You can also choose if this toggle should be at the top or the bottom.

Category logos

You can choose to have category logos auto-generated. This means that if a category has a Category Logo Image set in its category settings, that will appear to the left of the category name in the list.

You can also manually set each one using the custom logos setting.

Custom links

You can add links unrelated to your Categories, either above or below the Category list.
You can also set a Header before these links (which can also carry a link)

Category lock icon

This allows you to set an alternative category lock icon, for example unlock-alt !
image
to display in the Widget.

Theme translations

You can personalise the button labels on the Widget

2 posts were split to a new topic: Add support for category icons component

Hello! We are using this Category List Widget and loving how it allows us to organize categories so our users can easily know where they are in community. Thanks for open sourcing this great tool!

I am also using this Theme Component called : Discourse Category Banners and noticed a potential bug/conflict with this TCā€¦

https://www.loom.com/share/a38cc99bd0604876b2452722bf4a7eff

Hey @jord8on, yes, thatā€™s an alignment issue thatā€™s tricky to address, partly because there a number of possible components and customisations that can cause it (not just via the category banner theme component).

I do want to address this in a general fashion at some point, but Iā€™m still thinking over the best way to handle it so that it wonā€™t happen regardless of what other banners or theme components you use. There are a few banner components that cause this, and some standard discourse banners.

The only way you can semi-address this now is by using absolute positioning for the sidebar (itā€™s a site setting). Basically that means the sidebar will scroll with the rest of the page content rather than being fixed in place. You may not want absolute positioning for the sidebar though.

Ahhhā€¦ I like the way you alway seem to think about these types of thingsā€¦ not just a bandaid, but instead a universal fix. Iā€™ll be cheering you one. Sure wish I had the know-how to contribute some code for a universal fix. :disappointed:

I think youā€™re right, about absolute positioning. Thatā€™s prob not the direction we want to go.

Hi! I just installed this widget and it works beautifully except for when Iā€™m viewing our topics with the Kanban theme component view.
https://meta.discourse.org/t/kanban-board-theme-component/118164

Hereā€™s a screenshot of what I mean

image

See it live here: https://hub.youthpowercoalition.org/c/team/internal-comms/13/l/latest?board=default

Do you have suggestions for how to remedy this?

Iā€™m guessing Iā€™ll also need to bring this up on Meta with David, the person who created the Kanban Board Theme Component?

Iā€™m having the same problem, too, but I realize now that thereā€™s another solution.

Angus, could you point us in the right direction for what you use to show category descriptions in a way that doesnā€™t conflict with your layouts plugin?

Iā€™d like to do something similar to what you do for the Knowledge category, for example.

image

Also, Iā€™m not sure where I should be posting questions like this so do correct me if you want my topics to go elsewhere.

Thereā€™s a relatively straightforward solution to this problem that I didnā€™t think of before: sticky css positioning. Iā€™ve changed the layouts_sidebar_{side}_fixed site settings to a choice between:

  • fixed
  • absolute
  • sticky

If youā€™re using the Category Banners Theme component use sticky positioning.

Getting the layouts plugin to work with the kanban theme component will require itā€™s own independent styles as both of them take over the layout of Discourse, i.e. Iā€™m not sure it will make sense for either to change their structure in a ā€œgenericā€ fashion to make it possible to support the other. The change would be too specific to this particular problem.

I think I might help you out here though as I think this plugin needs an ā€œinteroperabilityā€ topic. Will post some CSS for Kanban interoperability there.

https://discourse.pluginmanager.org/t/layouts-interoperability

I donā€™t see this option currently, and Iā€™m wondering if itā€™s because I actually donā€™t know how to update a plug-in. Could you point me to directions on how to do this?

I assumed it would be from the Plug-in page but Iā€™m noticing that thereā€™s a missing checkmark next to discourse-layouts if that means anything at all.

image

UPDATE: Iā€™ve successfully updated the plug-in now. Thank you.

A post was split to a new topic: Tags route issue

A post was split to a new topic: Mobile display issue

Is there any way to automatically have the category hierarchy fully expanded, rather than hiding subcategories that arenā€™t part of the ā€œcurrent pathā€ to the topic or list being viewed?

I agree. It would be a very useful feature for less complex forums.

Iā€™ve got another thing - when I use sticky the position of the sidebar-container, it starts out 70px below the top, which is very annoying. Removing the 70px from the CSS doesnā€™t make it budge - the only thing that does is removing sticky. And sticky is much nicer aesthetically!

Sticky (what I want but canā€™t get it in the correct position)

image

Fixed (in the right position)

image

Any suggestions? Yes, at healthforum.nz

And wait - there is more!

I note that the button controlling the left hand widget hiding isnā€™t quite the right size, which looks a bit off. While I can target this by CSS easily enough, it would probably be better at your end.

What it is:
image

What I want:
image

Also, another nice enhancement would be to hide the now redundant Category dropdown (or have an option to do this) via the plugin rather than a bit of hacky CSS such as I used:

// hides category dropdown for desktop
.navigation-topics .category-drop {
display: none;}

Donā€™t you love engaged (but annoying) users?

Thanks @Nathan, @keegan or I will follow up here soon.

@keegan These are some nice discrete little open source tasks we can work on together. Letā€™s break them out into seperate topics. Perhaps in the #open-source:bug-reports or #open-source:feature-requests categories? Not 100% sure on the categorisation here. What do you think?

@angus Yes, I think there are some good ideas here we can work on. Breaking it up into bug reports and feature requests sounds good

A post was merged into an existing topic: [Category List Widget] Unable to scroll to reach bottom categories