Timeline for How to render a template in a module controller?
Current License: CC BY-SA 3.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 2, 2015 at 18:43 | comment | added | EmGee | @LhassanBaazzi I've included code above to show how to declare it. You'll need to create that template in your module 'html--my_module--template_file_name.html.twig'. | |
Dec 2, 2015 at 18:42 | history | edited | EmGee | CC BY-SA 3.0 |
adding code to explain something in comments.
|
Dec 2, 2015 at 18:05 | comment | added | Lhassan Baazzi |
@blakphyre how I can declare it ? some code please, for example for this templae html.html.twig
|
|
Dec 2, 2015 at 14:52 | history | edited | EmGee | CC BY-SA 3.0 |
Adding some clarity to an option in hook_theme().
|
Dec 2, 2015 at 14:50 | comment | added | EmGee | @Berdir I see what you're saying, I'll amend my answer to show that - I'm not sure about other other part, including a variable and passing it through the render array. I haven't done that yet myself. | |
Dec 2, 2015 at 14:46 | comment | added | Berdir | @blakphyre Drupal 7 automatically assumed a theme function with the same name if you did not specificy a template key. Drupal 8 automatically assumes a template with the same name(with _ => -, so template_name becomes template-name.html.twig) unless you specificy the function key explicitly. | |
Dec 2, 2015 at 14:18 | comment | added | EmGee | @Lhassan Baazzi, you'll need to override surrounding templates such as page.html.twig by creating your own module version called page--my_module--template_file_name.html.twig and then declare it in your hook_theme() like we did with the above template. | |
Dec 2, 2015 at 14:13 | comment | added | EmGee | @Berdir - what do you mean by template is the default now? | |
Dec 1, 2015 at 23:31 | comment | added | Lhassan Baazzi | Great! the content of the populate is displayed in the Bartik theme, how about if I want the template content to be displayed without to extend the Bartik theme ? | |
Dec 1, 2015 at 22:43 | comment | added | Berdir | Correct but the more common use case is variables, would be good to adapt that and e.g. include a variable and also how to specifically set it in the render array. Also, template is the default now in 8.x and no longer need to specified explicitly. | |
Dec 1, 2015 at 18:43 | history | answered | EmGee | CC BY-SA 3.0 |