Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By ilclaudio on
Hi all,
I've a custom-content type defined with the Drupal8 UI.
I'd like to modify the template of the node (node--mycontenttype.html.twig) that shows this content-type adding some sections which list the contents related to this node.
So I have to pass some arrays to the Twig template.
Which is the correct way to do this?
Should I use the preprocess function?
Thank you
claudio
Comments
Passing Extra data to node template Drupal 8
There are many many many ways to do this evan creating your own form display plugins then you can use in the UI.
this may lead you in the right direction.
this should give you an idea but you can set values etc then call them in your twig template.
I don't know if it is the
I don't know if it is the better way, but I've used "hook_preprocess_node" to pass an array to the custom view of the content type: node--mycontenttype.html.twig
So in the Twig template I can use the variable {{deadlines}}.
cld