Skip to content

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

Description

@paulRbr

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}})];
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions