Global Variables
Introduction
Currently there is only the template
global variable. Often times active entries (like a currently viewed page or post) are available on the template
variable for use elsewhere in the templating structure.
{% if template.post.id %}
<h1>{{ post.title }}</h1>
{% endif %}
Setting Values
You can set your own template variables for access anywhere by using the \Anomaly\Streams\Platform\View\ViewTemplate
within your PHP code:
$template = app(\Anomaly\Streams\Platform\View\ViewTemplate::class);
$template->set('meta_title', $page->getTitle());
You can also do this within views themselves. This can be helpful when content and layout are rendered separately and one (content) is injected into the other (layout) secretly.
{% do template.set('meta_title', page.title.value) %}