View only category

I don’t have exact solution for you. But I have good work around. Put the below code in admin/customize/body page.

<script>
var TopicTrackingState = require('discourse/models/topic-tracking-state').default;
function addCategories(model) {
    
    var categories = [
            { id: 200, name: "First Private Category", url: "/groups/my-group-page", color: "79a", description_excerpt: "hi, this is description"  },
            { id: 201, name: "Second Private Category", url: "/groups/my-group-2", color: "f9a", description_excerpt: "hi, this is description" }
        ];
        
    categories.forEach( function(item, index) {
        item.read_restricted = true;
        item.topicTrackingState = TopicTrackingState.create({});
        
       var category = Discourse.Category.create(item); 
       
        if (!Discourse.Site.currentProp('categoriesById')[category.id]) {
            if (model) {
                model.categories.addObject(category);   
            } else {
                Discourse.Site.currentProp('categories').addObject(category);
            }
        }
    });
    
}
Ember.run.later( function () {
    addCategories(); 
}, 1000);

var DiscoveryCategoriesRoute = require('discourse/routes/discovery-categories').default;
DiscoveryCategoriesRoute.reopen({
    afterModel(model) {
        addCategories(model);
    }
});
</script>

In above code you can add all private categories which you want to showcase by putting it in each lines like below

{ id: 200, name: "First Private Category", url: "/groups/my-group-page", color: "79a", description_excerpt: "hi, this is description"  },
{ id: 201, name: "Second Private Category", url: "/groups/my-group-2", color: "f9a", description_excerpt: "hi, this is description" }

Here id must match to the original category id and you should put relevant group’s url in the url field.

4 Likes