Using Custom Content Types and Field with Twig

Created on 11 July 2017, about 8 years ago
Updated 26 March 2025, 4 months ago

There isn't/wasn't documentation that covered how content created in the UI translated to fields that could be accessed via twig. The linked document (written a while ago) helps to fill that gap:

https://www.drupal.org/docs/8/theming/twig/using-custom-content-types-an...

📌 Task
Status

Needs review

Component

Missing documentation

Created by

🇨🇦Canada rthornton

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇿New Zealand quietone

    Can someone who know Twig verify that the page in the issue summary is up to date and can be added to the menu?

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇳India snehal-chibde

    hello @quietone, the page in the issue summary looks fine. There are certain corrections which i made to the page.
    Also I would suggest we can have dump function details added to this page.
    ie you can use dump in Twig templates if Twig debugging is enabled.
    {{ dump(variable_name) }}

  • 🇮🇳India adwivedi008

    Hello @snehal and @quitone
    Its better if we add that by simply adding {{dump( )}} you can print all available variables in the twig and then can use it further

  • 🇳🇿New Zealand quietone

    @snehal-chibde, thanks for confirming the content is correct. Because of that I have added it to the menu of the parent.

    Any further additions or updating of the content can be handled in on going basis which normally does not require an issue.

    I think this can now be closed. I am going to RTBC this because the page is available, which seemed the point of this issue. Change the status if you disagree.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    Is {{ node->field_my_title->value }} really correct Twig syntax?

Production build 0.71.5 2024