カテゴリ一覧にサブカテゴリが表示されないようにするにはどうすればよいですか?

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

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

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

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

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

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.

こんにちは。

私の状況では、親の下に2つのサブカテゴリをネストする非表示オプションを呼び出しましたが、その状況では最後のネストされたサブカテゴリのみが非表示になります。CSSを使用して、2つのレイヤーを非表示にすることはできますか?

例:
親カテゴリ
サブカテゴリ 1 - 非表示
サブカテゴリ 2 - 非表示

上記のシナリオで提供されたCSSは、サブカテゴリ2のみを非表示にします。

.category .subcategories {
      display: none;
    }

ありがとうございます。

ブラウザの開発者ツールで追加の要素を検査し、そのクラスをスタイル宣言に追加する必要があります。

返信ありがとうございます!

注:ネストされたカテゴリが3つ(通常は2つ)になる隠し機能を使用しました。

問題がより明確になる例を以下に示します。
例:メインページ:
テスト(カテゴリ)

  • テスト - サブ1(親テストカテゴリのネストされたカテゴリ)
    このシナリオでは、
.category .subcategories {
      display: none;
    }

は正常に機能します。
image
ネストされたテスト - サブ1カテゴリが表示されていないことがわかります。

さらにネストされたサブカテゴリを追加した場合:
テスト - サブ2カテゴリ、親はテスト - サブ1カテゴリ:


上記の画像でわかるように、テスト - サブ2はCSSコードにより非表示になっていますが、テスト - サブ1は非表示ではなくなっています。

問題は現在2つあります。
テスト - サブ1のタイトルを非表示にすることはできますが、クラスを display: none に設定すると、メインページ上のすべての親カテゴリも非表示になってしまいます。
2番目の問題は、ネストされたテスト - サブ1カテゴリだけを分離して非表示にできたとしても、それが占めるスペースは依然として存在し、問題となります。メインページには、それぞれ2つのネストされたサブカテゴリを持つカテゴリをさらに約20個追加したいと考えています。
理想的には、エンドユーザーがテストカテゴリをクリックするだけで、他のネストされたカテゴリなどにアクセスできるようにしたいと考えています。これは、
「このカテゴリのトピックの上にサブカテゴリリストを表示する」
およびサブカテゴリリストのスタイルを、例えば「ボックス」などに設定することで簡単に実現できます。

後でメインページに別のカテゴリをテストカテゴリの後に配置したい場合、20行の空白行などを避けたいです。

何か考えはありますか?

この Theme component を試してみてください

うまくいきました。ありがとうございます!