Modify SiteSettings/make SiteSettings mutable?

This is like a Feature - Dev topic, not sure which one it should be in.


Is there a way to modify site settings in a plugin? I’m 99% sure there isn’t, but I’d just like to confirm that.

If there isn’t, can I put forward a suggestion to not make it immutable? Or perhaps, having some API or a way to ‘unlock’ the immutable property of SiteSettings, perhaps?

A possible use case I’m looking at is to the include a list of protected categories to a setting such that it’s easier for the admin to include/exclude them.

Thanks.

לייק 1

Do you just want to change the value of site settings? Just do SiteSetting.whatever='new value. Or do you want to change something about them?

Don’t you just want to add a setting for that? Just add to config/settings.yml? something like

If that’s what you want, then using rake plugin:create[plugin-name] will create the settings file for you, complete with example.

Or maybe I don’t understand your question.

לייק 1

Let’s start here and work outside in.

Can you first describe the use case from the point of view of the community? What are they trying to accomplish and what makes that hard to do right now? What feature do you imagine solving their need more effectively (regardless of how it’s implemented)?

Then, we can work from there to determine if this is best done in a plugin or as a core feature.

Then, we can work from there to discuss suggestions for how to implement it.

לייק 1

@mcwumbly @pfaffman Thanks for telling me about

I wrongly assumed that since settings are ummutable in TCs, they are also as such in plugins in Ruby. I’ll give that a shot.

It would be nice to make them editable in TCs. My use case (which I am using a plugin for now) is that I take all topics and posts in all categories by default and do some stuff with them, but would not like to include protected categories (like a excluded_categories setting).

However, if it were possible to add protected categories to the setting, and then access it thereafter, it would be easier. This way, admins can include some protected categories if they want to by removing them from the setting.

With @pfaffman’s idea, it can probably be done, but not in TCs.

The problem with this is that I don’t know the protected categories beforehand.

If you’re logged in as an admin then a theme component could change siteSettings via the API.

Then just make a theme component setting and add those categories? You’re not referring to some protected_categories site setting that I’m not thinking of, are you? So something like this?

לייק 1

I would still love to know more.

Are you willing to share more about your community itself?

Are you the primary user of this feature or are there others on your team who need it? Do you have user facing documentation for the workflow that depends on this feature? If so, what does that look like? If not, can you describe briefly what it might look like?

I think answers to these kinds of questions would help me put this request in better context.

@mcwumbly @pfaffman Okay, let me try to explain this as much as possible.

I am developing a plugin that takes topics and posts and publishes them to GitHub as Markdown files (like an archive).

However, I would not like to include private categories (I think now that’s the correct term?) in this, since they are ‘private’.

Therefore, I am looking for a way to pre-fill a setting with the list of private categories, which can’t be defined within the default parameter, since I wouldn’t know what the private categories are beforehand.

In the event that this can be done by directly changing SiteSetting in Ruby, can the same be done with a Theme Component’s settings? I’m quite certain the latter is immutable. Is there any way to change it in a Theme Component?

Bear with me.

I still want to understand better from the perspective of the community team what problem you’re trying to solve.

What kind of community is this? Who runs it? Why do they want to duplicate their content on GitHub?

What problem are they trying to solve?

לייק 1

It’s not really about the community. I’m taking a shot at this (with a backfill job as well) in my own way. This saves each topic and post as a Markdown file in a repo.

לייק 1