Modifying Variables related to 'New Topic'

I’m trying to modify the behavior of tag-show.js's createTopicDisabled. I cannot seem to get this to be overwritten how I’ve seen on here.


I’ve tried using api.modifyClass() and api.modifyClassStatic() like this:

api.modifyClass("controller:tag-show", {
    @discourseComputed(
        "canCreateTopic",
        "category",
        "canCreateTopicOnCategory",
        "tag",
        "canCreateTopicOnTag")
    createTopicDisabled(
        canCreateTopic,
        category,
        canCreateTopicOnCategory,
        tag,
        canCreateTopicOnTag)
    {
        return false;
    }
})

And this:

api.modifyClass("controller:tag-show", {
    createTopicDisabled: function() { return false; }
)

And various other variations.


I’ve also tried grabbing the default controller & reopenning it, which worked fine when overwriting actions.

const TagShowController = require('discourse/controllers/tag-show').default;
TagShowController.reopen({
    createTopicDisabled: function() {
        return false;
    }
})

So far none of this has actually worked. Any help would be greatly appreciated.

1 Like