Answers.Body: <p>You will need to include your plugin handle, like:</p>
  
  <pre><code>$this-&gt;renderTemplate('myPluginHandle/index', array());
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-23T11:42:55.857Z
Answers.Text: 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}}
Answers.UserDisplayName: Volatil3
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-23T11:44:00.020Z
Answers.Text: You should have access to `{{ name }}` in you template now. That doesn't work?
Answers.UserDisplayName: crawf
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-23T11:46:16.440Z
Answers.Text: I was calling it before `{% set content %}` so guess it did not show between `{% set sidebar %}` and {% endset %}
Answers.UserDisplayName: Volatil3
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-23T11:40:14.327Z
Answers.LastActivityDate: 2015-10-23T11:40:14.327Z
Answers.UserDisplayName: crawf
Body: <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>
  
Tags: <plugin-development>
Title: Calling template from controller redirects to dashboard
ThreadText: # 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 %}  
  
  ---
  
  