Skip to content

brettdewoody/statamic-global-variable-editor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 

Repository files navigation

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

  1. Download and unzip the add-on.

  2. Drag _add-ons/globes into your site's _add-ons folder.

  3. Open _config/settings.yaml file and add globes:true to the _admin_nav setting. This will create a tab in the control panel to quickly edit your global variables.

  4. 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: you@yourdomain.com
  1. 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.

Click here to lend your support to: Globes - Statamic Add-on and make a donation at pledgie.com !

Thanks, and I hope you enjoy Globes and it makes your life better. Much, much better.

Changelog

v2

  • Addition of fieldtypes

v1

  • Initial Release

About

An add-on for the Statamic CMS to allow editing of a theme's global variables

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages