• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

How to add a variable to a Template?

tyteen4a03

Well-known member
#4
From the controller.

Thanks for your response.
Code:
        $viewParams = array(
            'variable' => "things",
        );

        return $this->responseView('ViewClassName', 'template_name', $viewParams); // The View class does not have to exist unless you are not outputting HTML or want to customize the output (which is rarely necessary)
Then use {$variable} to access it in the template. If you passed an array you use the Lua array access syntax: {$variable.someThing.moreThings.myValue}