Hide element if no data
You can stop an Element from rendering within your template when no data is entered into a specific Drupal field. This is useful when creating templates which render optional Drupal fields. If the website editor doesn't enter anything, you don't want the Element to render.
For example, you may have an image upload field within your Content type which renders an image into your Content template. If no image is uploaded, you don't want the image element to render anything. You can do this using the 'Hide if no data' option in the Image element.
To hide an element if no data in field:
- Double click on the Element on your Layout canvas you want to hide
- Click on the ...ellipsis tab to open the Elements menu
- Click on Hide if no data
- On the next screen, toggle on Enable
- Within the Data field, enter a token for the field you want to check is returning data. If you want to more than one field, enter multiple tokens
- If no data is returned, the element (and it's children) will not render.