Browse Source

Issue #3359592: Better explain $view_mode parameter for drupal_field()

merge-requests/33/merge
Julian Pustkuchen 1 year ago committed by Ivan
parent
commit
d7c8b28690
  1. 12
      docs/cheat-sheet.md

12
docs/cheat-sheet.md

@ -69,9 +69,21 @@ See [rendering blocks with Twig Tweak](blocks.md#block-plugin) for details.
## Drupal Field
```twig
{# Render field_image from node 1 in view_mode "full" (default). #}
{{ drupal_field('field_image', 'node', 1) }}
{# Render field_image from node 1 in view_mode "teaser". #}
{{ drupal_field('field_image', 'node', 1, 'teaser') }}
{# Render field_image from node 1 and instead of a view mode, provide an array of display
options, which is documented here: https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!EntityViewBuilderInterface.php/function/EntityViewBuilderInterface%3A%3AviewField #}
{{ drupal_field('field_image', 'node', 1, {type: 'image_url', settings: {image_style: 'large'}}) }}
{# Render field_image from node 1 in view_mode "teaser" in English with access check disabled. #}
{{ drupal_field('field_image', 'node', 1, 'teaser', 'en', FALSE) }}
{# Render field_image from node 1 in view_mode "full" (default) with access check disabled (named argument). #}
{{ drupal_field('field_image', 'node', 1, check_access=false) }}
```
## Drupal Menu

Loading…
Cancel
Save