I have a custom timber function total_value in my twig.php file and in the Twig class.
class Twig {
public $totalvalue = 1;
public function add_timber_functions( $twig ) {
/* actions and filters */
$twig->addFunction(new Twig_Function('total_value', function ($value) {
$this->totalvalue += $value;
return ($this->totalvalue);
}));
}
}
I also have a public variable in the Twig class public $totalvalue = 1;
If I call the function from one twig template like so {{ total_value('1') }}, it returns 2, as it should. But when I call it from another twig template after that it still returns 2, but I would like it to return 3.
Im very new to twig and timber and i cant really wrap my head around it
$_SESSION- DarkBee