How are theme setting fields created?

When you import the theme below from Github, “theme settings” appear set under Customize > Theme > Theme_Name.

Theme_Settings

The Github files include a YML file with the theme settings inside it. The “Import theme” process presumably uses that YML file to make the setting fields appear. But, when I’m writing my own theme (not plugin), how do I create theme settings / parameters like this?

2 Likes

This should be what you are looking for :slightly_smiling_face:: How to add settings to your Discourse theme

8 Likes

How did I miss that topic!

Looks like it can’t be done via the interface and requires the files to be placed on Github. Never posted on Github before, so will have to give it a try, to test myself.

Thank you.

3 Likes

No problem :slightly_smiling_face:

You don’t technically need to do anything on GitHub, the Discourse Theme CLI (console app to help you build themes) is really all you need to get started. It’s an extremely handy tool and easy to set up. I highly recommend giving it a try!

3 Likes

Does anyone know how one would access variables in the theme settings in Javsscript?

<script type="text/discourse-plugin" version="0.8.13">
    console.log(themeSettings.myvalue); 
</script>

I keep getting “themesettings is not defined” in the dev tools

You almost had it. It’s actually just settings not themeSettings :slight_smile:

5 Likes

Thank you @tshenry! I also had it in the wrong file.

My code was in /common/header.html instead of /common/head_tag.html

Thank you for your help! :slight_smile:

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.