Hide categories according to user group membership

Continuing the discussion from How to split the forum into two main parts (general/groups) and how to display only subcategories I can create a new post in?:

Hey everyone,

Here is a theme component that does a thing I’ve been wanting to do for a long time, but I’d like your comments on the code to improve it, or your suggestions.

I don’t believe the code is very good so I don’t want to recommend it before it has been checked by someone else.

What it does

Hide with CSS all the topics for which the user has a category permission restriction in chosen pages.

Repository

Repository link
framagit.org/oca/discourse-theme-shroud-subcategories

Motivation

I’ve got a community with a lot of groups, and I want people to peacefully ignore what is from other groups than theirs. I don’t want to restrict access to the content, I just don’t want it to be on main page. They should be able to access it by going for it, by choosing to go on this category specifically (for example, in order to know what is discussed here). Obviously, the relevant tool would be the watch/ignore function, but since the UI requires more than 2 clicks to set it up, no-one in the community uses it. Some improvement on the Category page might do the trick but they are out of my skill.

So, I use what UI is simple enough for them: the group page. On the same page are displayed all the groups they can access, freely or not, and their description. That’s perfect, they just need to click and chose them. The group page is too hidden for them (inside the hamburger) so I could put a big button link on the main page.

Now, I need to link the group membership and the display of the category posts.

How it works

The trick I used was to setup the category permission as:

  • everyone: read, write
  • that group: start a message, read, write

and then, for each topic in the list, check if there is a category restriction, and if yes, add a class not-in-group to the topic element.

Then, the CSS add display:none accordingly.

UI

The admin can chose the pages where this behaviour is effective. It should not be done on the category page because, by definition, that is where we want to access the content. On my website, all those groups are subcategories that are hidden from the latest page, we access it through the /c/groups/ page, so that is that page which is used.

Improvements

  • Being able to select parents category of the filtered categories (so any category that is not a child of this one is safe from being skipped)
  • Add tags, so that if a topic has this tag, then it will not be removed.
10개의 좋아요

This does not make sense to me. Why not use category permissions to restrict what the groups see?

4개의 좋아요

Because I want them to be able to see those categories, but only if they make the effort to reach it. For example, in order to see what is discussed on that specific project before they register.

But on the main page, I don’t want them to be spammed by topics they don’t care. The best way would be for them to ignore it with the watch/ignore, but that’s too complicated for them. The other option would be to register in the group, go to the category page to read what is discussed, and then unregister from the group. That’s too many clicks for most of them, plus they would not dare do it.

Last option is the category setting «remove from latest» but that setting affects all the users, even the one that are following that category. With this method, I do have the equivalent of the «remove from latest» but only for some users and for all the pages I want.

Hope it’s more clear.

2개의 좋아요

이러한 개선 사항들은 완료되었습니다.

4개의 좋아요

이 내용은 매우 흥미롭습니다. 이 컴포넌트가 설치된 예시를 보여주실 수 있나요, 아니면 해당 컴포넌트가 설치된 포럼에 참여할 수 있을까요?

1개의 좋아요

그리고 이 구성 요소로 필터링하면 요약 이메일로 게시물이 전송되지 않게 되나요? 그렇다면 정말 대단할 텐데요.

1개의 좋아요

아니요, 그렇지 않습니다.
이것은 게시글에 대한 접근 권한을 제거하는 것이 아니라, CSS로 단순히 숨기는 것입니다.
게시글은 여전히 사용자에게 전송되며, 표시하지 말라는 지시와 함께 전송됩니다.
사용 사례는 접근 권한을 제거하는 것이 아니라, 메인 페이지(또는 선택한 다른 페이지)에서 표시를 제거하는 것입니다.

죄송합니다. 로그인 없이 접근 가능한 포럼에 설치해 보지 못했지만, 여기나 개인 메시지로 질문을 자유롭게 해 주세요.

2개의 좋아요

감사합니다!

이 부분이 무슨 뜻인가요?

1개의 좋아요

페이지 소스 코드를 살펴보면 주제 정보가 전송되고 있음을 확인할 수 있습니다. 그러나 테마 컴포넌트는 이를 무시하도록 지시합니다.

1개의 좋아요

이것은 단순히 탐색 시 항목의 표시(DISPLAY)만 처리하는 기능일 뿐입니다. 음소거나 무시 기능이 아닙니다. 하지만 몇 가지 용도에서는 이 해결책이 매우 흥미롭다고 생각합니다. @oca님, 좋은 작업 축하드립니다!

2개의 좋아요

좀 더 자세히 살펴보겠습니다. 다시 한번 감사합니다!

1개의 좋아요

안녕하세요, 이 테마 컴포넌트를 설치했는데 설정하는 데 문제가 있습니다. 태그와 필터링된 카테고리를 선택하려고 해도 제 항목이 표시되지 않습니다. 예를 들어, 저희에는 분명히 faq 태그가 있지만 선택할 수 없습니다. 태그를 직접 입력해 보기도 했는데, 이것도 작동하지 않습니다.

2개의 좋아요

대시보드에서 태그 기능이 활성화되어 있나요? 설정/태그 메뉴에서 찾을 수 있습니다. 태그 목록 상단의 첫 번째 항목을 통해 태그 기능을 활성화할 수 있습니다. 활성화한 후 생성한 태그들이 정상적으로 작동해야 합니다.

1개의 좋아요

네, 태그가 활성화되어 있습니다.

1개의 좋아요

설정 파라미터는 어떤 태그가 존재하는지 알 수 없습니다. 여기에는 태그 이름을 직접 입력해야 하며, create: 'faq'를 클릭하면 태그 이름이 선택됩니다. 필요한 만큼 여러 태그를 선택할 수 있으며, 그중 하나만 있어도 게시물을 다시 표시하는 데 충분합니다.

주의하세요. 계정에 관리자 권한이 있으면 모든 카테고리에 대한 완전한 권한이 부여됩니다. 하지만 카테고리를 숨기는 기능은 해당 계정이 실제로 새 게시물을 생성할 수 있는지 확인하는 방식으로 작동합니다. 사용자의 계정은 생성이 가능하므로, 모든 곳에서 모든 게시물을 볼 수 있습니다. 이 컴포넌트를 테스트하려면, 일반 사용자가 보는 것과 동일한 환경을 확인하기 위해 테스트 계정을 만드는 것을 권장합니다.

2개의 좋아요

감사합니다. 작동하는 것 같아서 정말 기대됩니다. 귀한 도움에 감사드립니다.

2개의 좋아요

특정 카테고리를 추적하는 사용자에게 예외를 적용할 수 있을까요?

1개의 좋아요