On some projects we may need global options to control the behaviour of the site. For my latest project I needed some theme options to set some styles, fonts etc. That’s because I may set up similar sites in the future with the same base.
We can approach this in at least two different ways. Site options or config options. I’ve tried both and I realize now that I’ve used site options too much.
With this I mean the site page form in the panel.
- Users without code experience can set up whatever they need, because it’s in the panel.
- It’s perfect for images, because they are easy to just drag in and add to an image field. It’s also simple to get in a template/snippet.
- We don’t need the code editor to change these options.
Use it when your users needs to have access to the options. Also use if your options are images and you find them easier to handle in the panel.
With this I mean
config.php in the
- When we build our site with code, it’s easier to open a config file than logging in to the panel.
- It’s less code and therefor less work and less to maintain. We don’t need to edit a blueprint file etc.
Use it when your users does not need to have access to your options. It’s especially good for types that are not images.
If you are going to use images as options without the panel, you need to find a simple way for it. One way is to use predefined filenames that never changes, like
hero.jpg. With such names you don’t even need an option in the first place.
Config options may be better than you think. Or the other way around, you may be overdo things with site options. Do the unexperienced users really need all that site options? Maybe you can cut half of it? I learned the hard way that I can cut most of it and only keeping it in the config options.