Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show parent-parent category logo in case of deeper nested categories #5

Open
paulRbr opened this issue Mar 24, 2023 · 0 comments
Open

Comments

@paulRbr
Copy link

paulRbr commented Mar 24, 2023

Since a few years now, Discourse has support for higher level of depth in the category tree (with the max_category_nesting setting).

Would it be possible to show the highest-level parent category logo (and name) within this extension? Or at least support up to 3 level deep categories (That's the max level supported by the discourse community for now).

E.g. in https://github.com/naidihr/discourse-category-headers/blob/8266ad8458b45d9384a2c6149c22fd22cc0a79ec/common/header.html

Could probably end-up like (but I have now idea of how the extension work so please let me know how I can help):

function logoImg() {
  const parentCategory = category.parentCategory;
  const grandParentCategory = parentCategory && parentCategory.parentCategory;

  if(settings.show_category_logo) {
    if (category.uploaded_logo) {
      return [h('img',{"attributes" : {"src" : category.uploaded_logo.url}})];
    } else if (settings.show_parent_category_logo && parentCategory && parentCategory.uploaded_logo) {
      return [h('img',{"attributes" : {"src" : parentCategory.uploaded_logo.url}})];
    } else if (settings.show_parent_category_logo && grandParentCategory && grandParentCategory.uploaded_logo) {
      return [h('img',{"attributes" : {"src" : grandParentCategory.uploaded_logo.url}})];
    }
  } else if (settings.show_site_logo && siteSettings.logo_small) {
    return [h('img',{"attributes" : {"src" : siteSettings.logo_small}})];
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant