Como faço para ocultar uma subcategoria da lista de categorias?

I can’t figure out how to get a subcategory (“Build your own teen innovation challenge” in this case) to stop showing up (the arrow) on the main category page. I’ve tried several things. Can you help?

2 curtidas

I can’t find a site setting for this but you could hide it using CSS in a theme component.

Could use this CSS:

.category .subcategories {
      display: none;
    }

If you also don’t want them listed on the hamburger drop-down menu:

.category .subcategories, .category-links .category-link.subcategory {
  display: none;
}
3 curtidas

So I’m familiar with CSS but not sure where to add it for Discourse to use it.

On the mobile so from memory but it’s something like this:

Admin
Customise
Themes
Components
Install (add name for new component)
Edit HTML/CSS
Apply theme component to themes

2 curtidas

Another option… you could assign the sub-category to a group and restrict visibility to that group. Just fyi.

Would that have other consequences beyond the main categories page? I’ve not used groups yet.

You create a group called “Team Kids” then define who can join/view/participate in that group.

  • Add a description, allow certain people to be “owners” who can moderate the group vs regular members.

Create a Category as we did for “Classes & Events”

  • assign read/write/view access to the group under /Edit /Security for the category
  • Notice how you can also change settings for “Everyone”, which includes all anonymous guests on the web, etc.

OR

Simply stop the sub-category from showing up for @everyone. We restrict categories to only @trust_level_0 users, which means registered users who are logged in. Or, @trust_level_1 users who’ve been active on the platform a few weeks. These trust levels are actually all groups, too.

Hopefully this gives you some ideas on restricting your categories, rather than simply allowing them all to be crawled by google searches and viewed by random people online.

These are all very good suggestions; thank you. Ultimately, I was trying to create an Events group and then, in some cases, subgroups for the events underneath them. It’s an archive sub at this point, so I don’t need it front and center but don’t want to delete it.

Combined with @manuel’s CSS above, this worked perfectly. Thank you.

2 curtidas

Category Group access is defined within each specific category, so you have total control over any access a group will (or will not) actually have to a category. “Trust Levels” of users in Discourse, Staff, Admins, Moderators… all of these are literally just groups.

This has been educational for me, so thank you, but I think you are solving a different problem to the one described in the original post. I get the impression he just wanted rid of the sub-category from the main categories page, but wanted it to behave normally otherwise.

1 curtida

These are the only ways I know to suppress a category: by group. The trust levels are all groups. Use or ignore as you please.

Olá,

Na minha situação, invoquei a opção oculta para aninhar 2 subcategorias sob uma categoria pai e, nessa situação, apenas a última subcategoria aninhada fica oculta. Existe uma maneira, via CSS, de ocultar duas camadas de profundidade?
Por exemplo:
Categoria Pai
Subcategoria 1 - ocultar
Subcategoria 2 - ocultar

O CSS fornecido aqui no cenário acima oculta apenas a subcategoria 2.

.category .subcategories {
      display: none;
    }

Obrigado.

Você precisaria inspecionar o elemento adicional com as ferramentas de desenvolvedor do seu navegador e, em seguida, adicionar sua classe à declaração de estilo.

Obrigado pela resposta!

Observação: Eu invoquei o recurso oculto que permite uma categoria aninhada extra, 3 no total em vez de 2.

Aqui está um exemplo que pode ilustrar melhor o problema:
por exemplo, Página Principal:
Teste (Categoria)

  • Teste - Sub 1 (Categoria aninhada da Categoria Pai Teste)
    Neste cenário,
.category .subcategories {
      display: none;
    }

funciona bem.
image
Como você pode ver, a categoria aninhada teste - sub 1 não é exibida.

Se eu adicionar outra subcategoria aninhada:
teste - sub 2 categoria, com sub 1 categoria como seu pai:


como você pode ver na imagem acima, teste - sub 2 está oculto
de acordo com o código CSS, mas teste - sub 1 não está mais oculto.

O problema agora é duplo:
Posso ocultar o título teste - sub 1, definindo sua classe como display: none, mas isso também oculta todas as categorias pai na página principal.
O 2º problema é que, mesmo que eu pudesse isolar e ocultar apenas a categoria aninhada teste - sub 1, o espaço que ela ocupa ainda está lá e será problemático, preciso ter cerca de 20 categorias a mais na página principal com duas subcategorias aninhadas cada.
Idealmente, eu só quero que o usuário final possa clicar na Categoria Teste e ter acesso às outras Categorias aninhadas, etc., o que é facilmente realizado, via
Mostrar lista de subcategorias acima dos tópicos nesta categoria.
e definindo: estilos da lista de subcategorias como, por exemplo, caixas, etc.

Se em algum momento eu quiser posicionar outra Categoria da página principal após a Categoria Teste, não quero 20 linhas de espaço em branco, etc.

Pensamentos?

Experimente este Theme component

Funcionou bem - obrigado!