<p>You will need to include your plugin handle, like:</p>

<pre><code>$this-&gt;renderTemplate('myPluginHandle/index', array());
</code></pre>

CC BY-SA 3.0
2015-10-23T11:42:55.857Z
It worked but partially, variable is not being passed, this is what I did:

`return $this->renderTemplate('pluginHandle/index',array('name' => 'Adnan'));`

In template I called {{name}}
Volatil3
CC BY-SA 3.0
2015-10-23T11:44:00.020Z
You should have access to `{{ name }}` in you template now. That doesn't work?
crawf
CC BY-SA 3.0
2015-10-23T11:46:16.440Z
I was calling it before `{% set content %}` so guess it did not show between `{% set sidebar %}` and {% endset %}
Volatil3
CC BY-SA 3.0
2015-10-23T11:40:14.327Z
2015-10-23T11:40:14.327Z
crawf
<p>How can I call a template with variable from a controller method? I tried following but it redirects to dashboard:</p>

<pre><code>public function actionsetDate() {
        return craft()-&gt;templates-&gt;render('index');
    }
</code></pre>

<plugin-development>
Calling template from controller redirects to dashboard
# Calling template from controller redirects to dashboard

(Asked by: username_0 on 2015-10-23)

How can I call a template with variable from a controller method? I tried following but it redirects to dashboard:
public function actionsetDate() {
        return craft()->templates->render('index');
    }

**Tags:** plugin-development

---

## 1 answers

### Answer by username_1 on 2015-10-23. Score: 2

You will need to include your plugin handle, like:
$this->renderTemplate('myPluginHandle/index', array());

> **Comments:**
> **username_0**: It worked but partially, variable is not being passed, this is what I did:  `return $this->renderTemplate('pluginHandle/index',array('name' => 'Adnan'));`  In template I called {{name}}  
> **username_1**: You should have access to `{{ name }}` in you template now. That doesn't work?  
> **username_0**: I was calling it before `{% set content %}` so guess it did not show between `{% set sidebar %}` and {% endset %}  

---

