Coming to Craft after years with EE, I feel like a newbie again.

I painfully managed to built and install a basic plugin for craft3 with composer, (with a little help from the docs and NYstudio107's tutorial).

For now, the plugin does nothing, and to keep going, I would need to understand how to translate a pattern commonly used in EE. Get some data from a template, process it and return it.

Get tag data and parameters

$data_to_process = ee()->TMPL->tagdata;
$process_param = ee()->TMPL->fetch_param('parameter');

Output content to template

ee()->return_data = $processed_data;

Ho do you do such things in craft ?

1 Answer 1


If you want to render a template in Craft 3 you can do

$html = Craft::$app->getView()->renderTemplate('path/to/template', $variables);

If you want to return/render a template within your Controller action you can do

return $this->renderTemplate('path/to/template', $variables);

If you want to render a plugin template you'll need to attach your plugins handle to your path


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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