This module allows administrators to create and edit system-wide variables through the Drupal administration interface. These variables can be used in CSS files like a preprocessor, delivered as JSON, and imported/exported between Drupal installations. They can also be accessed within templates and CKEditor.
Overview
Create and edit system wide variables via the administration interface.
Easy to use for editors.
We have developed this module for a conference platform to solve the following tasks:
- Store, call and edit system wide variables in a Drupal installation
- Place and edit variables in CSS files (it works a little bit like a CSS preprocessor)
- Deliver simple key value pairs as JSON, as a static file or via a Drupal route (since 2.2.0)
- Manual import and export (as JSON) between Drupal installations. Can also be used for simple backups of the modules configuration and data.
Configuration
You find the configuration page of the Editablevars module below this link:
/admin/config/system/editablevar
You can create there "variable groups", to organize your variables and choose the favored type of group ("Simple" vs "File" vs "JSON").
In templates you can use the variables f.e. like this:
{% if editablevar('showhide_widget_chat', 'show') == 'show' %}
{{ widget_chat|raw }}
{% endif %}
or
{% set statistics_in_head = editablevar('template_head_statistics', '') %}
{{ statistics_in_head|raw }}
or
<div id="meta" style="background-color:{{ editablevar('style_header_meta_background', 'white') }};">
("white" is the default)
CKeditor5
You can also call the variables in the CKeditor5 as token. There is a content filter available.
JSON via Drupal route (since 2.2.0)
Variable groups can also be delivered as JSON directly through Drupal, without writing a file:
/editablevar/json/{group_id}
Enable it per group with "Enable direct download of JSON File" in the group settings and grant the permission "Download editablevars as JSON" to the roles that may read it (e.g. anonymous for a public headless frontend). This avoids CORS problems with certain server configurations, when a decoupled frontend reads the variables from another domain.
After updating from 2.1.x, run drush updb (adds the column download_enabled).
Ask your assistant about Editablevar
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
- user Drupal core
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.