Defining Globals


A global variable is like any other view variable, except that it's available in all views and macros. This article will show you how to define them and return usable information.

Defining Globals

Override the getGlobals method within your plugin class to get started:

<?php namespace Test\FooPlugin;

use Anomaly\Streams\Platform\Addon\Plugin\Plugin;

class FooPlugin extends Plugin

     * Returns a list of globals.
     * @return array An array of functions
    public function getGlobals()
        return [
            'version' => 'v1.2.250'

Defining Basic Globals

Globals can return basic data as-is to be used in any view or macro anywhere. The above example will provide the following global:

{{ version }} // v1.2.250