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

Variable from ControllerPublic to template

Discussion in 'XenForo Development Discussions' started by account8226, Dec 13, 2012.

  1. account8226

    account8226 Guest


    I am trying to send out a variable I have in ControllerPublic (actionIndex) to a template I made.

    How can I do this ?

    Between, have you got any good xenforo tuts to starts developing add-ons ?

  2. James

    James Well-Known Member

    Have you returned a response? In the controller, you'll pass something like:
    return $this->responseView('XenForo_ViewPublic_Forum_View''forum_view'$viewParams);
    Your $viewParams are the variables exposed to the template, where "forum_view" is your template.
    Jake Bunce likes this.
  3. account8226

    account8226 Guest

    Yes I did, here is my view params :
    $viewParams = array(
                    '1' => "Hey",
                    'id' => $var
  4. James

    James Well-Known Member

    So now in your template you can use {$1} and {$id}, provided you passed them to the responseView.
    Jake Bunce and Elly like this.
  5. account8226

    account8226 Guest

    Amazing ;) Thanks for the help, it is working :)

Share This Page