1. 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?

Discussion in 'XenForo Development Discussions' started by maman, Jan 22, 2014.

  1. maman

    maman Member

    In case it is not originally part of it?

    Thank you in advance.
  2. tyteen4a03

    tyteen4a03 Well-Known Member

    Is the variable used only in-template, or supplied from the controller?
  3. maman

    maman Member

    From the controller.

    Thanks for your response.
  4. tyteen4a03

    tyteen4a03 Well-Known Member

            $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}
    maman likes this.
  5. maman

    maman Member

    Many thanks!

Share This Page