Globals

Textstem globals are items of content available anywhere at any time. Each global has a type, which sets how its value is stored, how you edit it in the admin, and what templates get back when they use it:

Name Underlying data type Input editor Returned value
string Text Text box String
html HTML Rich text editor String of HTML
number Number Number field Float
boolean 0 or 1 Yes/no toggle Integer, 0 or 1
json JSON JSON editor Array (empty if the JSON is invalid)
array JSON array JSON editor Array
list JSON array of label and value pairs Rows of name and value fields Array of ['label' => …, 'value' => …]
pages JSON array of page IDs Page picker Collection of pages, in the order picked

Globals can be accessed in your app via the Textstem facade:

 $value = Textstem::globalVar('my-key');

They are also available in your blade templates via the $globals variable:

{{ $globals['my-key'] }}

They are also available in blocks of content using the get template command:

{wrt get var="my-key"}

X-Articles are a special template components designed to work with globals. They are used to enable CMS administrators to edit chunks of text that are included in templates or other components (such as a company address that appears in the footer of each page, or the prompt for a sign-up form). Essentially they are globally available variables that can be defined in templates using the component.

For example, a template may have some markup like this in the footer

Sign up to our newsletter

When creating templates for the site, developers can wrap the editable text in an component like this:

code snapshot

The first time the page is viewed and this template is rendered, a global will be created with the key "signup-prompt" and the html value "Sign up to our newsletter". This text can now be edited in the admin system

See also: Globals, for reading globals in code and creating new types.

esc