Plugin

This section will go over how to use the plugin that comes with the Variables module.

variable

The variable function returns the field type presenter for the variable specified in a given group.

Returns: \Anomaly\Streams\Platform\Addon\FieldType\FieldTypePresenter or null
Arguments
Key Required Type Default Description
$group true string none The slug of the group you want to access.
$field true string none The slug of the variable field in the group you want to access.
Twig
{{ variable('social', 'facebook_url').link('Facebook')|raw }} // <a href="http://facebook.com/pyrocms">Facebook</a>

variable_value

The variable_value function returns the raw data for the variable specified in a given group.

Returns: mixed
Arguments
Key Required Type Default Description
$group true string none The slug of the group you want to access.
$field true string none The slug of the variable field in the group you want to access.
Twig
{{ variable_value('social', 'facebook_url') }} // https://facebook.com/pyrocms

variable_group

The variable_group function returns the entire decorated group entry model so you can then easily access any variable on said model.

Returns: \Anomaly\Streams\Platform\Entry\EntryPresenter or null
Arguments
Key Required Type Default Description
$group true string none The slug of the group you want to access.
Twig
{{ variable_group('social').facebook_url }} // https://facebook.com/pyrocms (__toString output)
{{ variable_group('social').facebook_url.value }} // https://facebook.com/pyrocms (raw value)
{{ variable_group('social').facebook_url.link('Facebook') }} // <a href="https://facebook.com/pyrocms">Facebook</a>

// Or set as a Twig variable

{% set group = variable_group('social') %}

{{ group.facebook_url.link('Facebook') }} // <a href="https://facebook.com/pyrocms">Facebook</a>