Passing an array on Template Render I am trying to pass an array on template render like this:



public function actionConfirm()
{
   $variables['confirm'] = array(
      'name'   => 'Silvanus',
      'office' => 'OOTS',
    );
    $this->renderTemplate('confirm', $variables);
}



And output it in layout like this:



{%for variable in variables%}
  {{variable.name}}
  {{variable.office}}



This is just an example, mainly after client pays using paypal I get a payment Object that I want to pass it to the confirmation layout as per explanation above. I have tried it doesn't work.

Anyone has an idea on how to achieve this?

Thanks

Cheers.
Yes, you do it with the setRouteVariables mathod on UrlManager, like this:

craft()-&gt;urlManager-&gt;setRouteVariables(array(
    'variable' =&gt; array(
      'name' =&gt; 'silvanus',
      'office' =&gt; 'OOTS
    )
));

$this-&gt;renderTemplate('confirm');


Now you can access your variables like this in your template:

{{ variable.name }}
{{ variable.office }}


Check out the documentation on Controllers, there's an example.

EDIT:
The above method is how I've done it in the past, but I see now that the renderTemplate method also can be used. I think the problem is just how you access it in your templates, I think you should just do:

{{ confirm.name }}
{{ confirm.office }}