1

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');
    }
2

You will need to include your plugin handle, like:

$this->renderTemplate('myPluginHandle/index', array());
3
  • 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
    Oct 23 '15 at 11:42
  • You should have access to {{ name }} in you template now. That doesn't work?
    – crawf
    Oct 23 '15 at 11:44
  • I was calling it before {% set content %} so guess it did not show between {% set sidebar %} and {% endset %}
    – Volatil3
    Oct 23 '15 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.