Helpful Drupal 9 Code Snippets

2 weeks 7 hours ago

I continually went to my views embed code through the life of Drupal 7.  So lets continue that tradition with posting some of the snippets that are helping the most with Drupal 9.

Print raw field value (twig)

{{ content.field_page_format|render|striptags|spaceless }}

Print the content without some fields (twig)

{{ content|without('field_header_image','field_page_format') }}

Embed a view with arguments (twig)

{{ drupal_view('article_listing', 'block_6', node.id) }}

< Return to Code Listing