The method $this->addTwigGlobal($name, $class) adds a global variable to Twig.

  • @param: (string) $name. The name of the global variable.
  • @param: (mixed) $class. The value of the global variable.

Example Usage


namespace Plugins\Myplugin;

use \Typemill\Plugin;

class Myplugin extends Plugin

    public function myFunction()
       $this->addTwigGlobal('text', new Text());

This will add the class Text() to the variable 'text', which you can use in your twig-templates like this:

  {{ text }}

Read the Twig-Documentation for more details.