Theme Options
Theme options allow administrators to configure theme appearance without editing template files. Declared in theme_info.json, stored in theme_options table, accessed in templates via the theme_options object.
Option Types
checkbox
"show_sidebar": { "type": "checkbox", "label": "Show Sidebar", "default": "1" }
{% if theme_options.show_sidebar %}{! widget_area "sidebar" !}{% endif %}
text
"footer_copyright": { "type": "text", "label": "Footer Copyright Text", "default": "" }
{{ theme_options.footer_copyright }}
select
"sidebar_position": {
"type": "select",
"label": "Sidebar Position",
"default": "right",
"choices": { "right": "Right Side", "left": "Left Side", "none": "No Sidebar" }
}
{% if theme_options.sidebar_position == "none" %}
<div class="col-12">{% block content %}{% endblock %}</div>
{% else %}
<div class="{{ cls.cls_col_main }}">{% block content %}{% endblock %}</div>
<div class="{{ cls.cls_col_sidebar }}">{! widget_area "sidebar" !}</div>
{% endif %}
textarea
"custom_css": { "type": "textarea", "label": "Custom CSS", "default": "" }
{% if theme_options.custom_css %}
<style>{{ theme_options.custom_css | raw }}</style>
{% endif %}
Storage and Defaults
Values stored in theme_options table per theme. On activation, default values are inserted for options without a stored value. Existing admin customisations are never overwritten on re-activation.
Admin UI
The Appearance → Theme Settings page auto-generates a form from the options schema. Each type renders as the appropriate form control. No PHP needed in the theme.
Best Practices
- Keep options minimal — every option adds admin complexity
- Use sensible defaults — the theme should look good with zero configuration
- The
labelshould clearly communicate what the option controls - For
textareawith CSS, always use| raw— never escape CSS output