statamic-global-variable-editor
statamic-global-variable-editor copied to clipboard
An add-on for the Statamic CMS to allow editing of a theme's global variables
Statamic Add-on - Global Variable Editor
By Brett DeWoody (2015) Version 2.0.0
An add-on for the Statamic CMS to edit global variables through the control panel. Useful for editing common snippets of text used on the site.
Installation & Setup
-
Download and unzip the add-on.
-
Drag
_add-ons/globes
into your site's_add-ons
folder. -
Open
_config/settings.yaml
file and addglobes:true
to the_admin_nav
setting. This will create a tab in the control panel to quickly edit your global variables. -
Open
_themes/[theme-name]/theme.yaml
file and define the global variables you want to be editable.
To make a variable editable, first create a first-level var of globals
, then nest your variables under the globals
var.
For example, if you wanted to have an editable phone number global variable you would do this.
globals:
-
name: phone
display: Phone
value: 555-555-5555
If you wanted to add another global variable, say an email address, your globals
variable would look like so:
globals:
-
name: phone
display: Phone
value: 555-555-5555
-
name: email
display: Email
value: [email protected]
- Display the global variables in your template using the
{{ globes }}
tag. In our example from before, if we wanted to display the phone number we would add{{ globes name='phone' }}
to our templates or layouts.
Fieldtypes
Global variables can use a limited set of the built-in fieldtypes in Statamic. Define the fieldtype using the type
parameter. If no type
is set the global variable will default to a text
type.
globals:
-
name: phone
display: Phone
type: redactor
value: 555-555-5555
The allowed types are:
-
checkbox
-
checkboxes
-
date
-
markitup
-
radio
-
redactor
- no file uploads however -
select
-
tags
-
table
-
text
-
textarea
-
time
-
users
Usage
You'll have a new tab in your admin panel labeled Constants
. Clicking the tab will display your editable global variables and give you the option to edit them.
To change a value, simply enter the updated value then click the Save & Publish button at the bottom.
Beer Me
If you find the add-on useful and use it on projects consider buying me a beer. No pressure, but you'll make me happy and help keep Globes up-to-date.
Thanks, and I hope you enjoy Globes and it makes your life better. Much, much better.
Changelog
v2
- Addition of fieldtypes
v1
- Initial Release