Globals

Textstem globals are items of content available anywhere at anytime. There are several different types of global, including -

  • html
  • text
  • array
  • json

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 wranger template command 'get' 

{wrt get 'my-key'}

Heads up!

Any globals marked as 'lazy' are not loaded into the page global array. To access these, you need to use the global() method;

X-Articles

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

<p>Sign up to our newsletter<p>

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

<ts-x:article key-name="signup-prompt"><p>Sign up to our newsletter<p></ts-x:article>

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