Drupal Answers Asked by MrFox on December 12, 2020
I want to embed a video on a page.
How do I display the field_media_video_embed_field in my twig?
The complicated thing about this is that I am using a view inside tabs.
{{ kint(programme.video) }}
gives me the following output.
In my theme I have used the following code.
$programmes = [];
$view = Views::getView('participating_programmes');
$view->execute();
foreach ($view->result as $row) {
$video = $row->_entity->get('field_pvideo')->referencedEntities();
$programmes[$nid]['video'] = $video;
}
Ideally I want to embed the video, but I would be happy if I could just get the field_media_video_embed_field and work from there.
It's unclear whether you want to get one or multiple videos:
// get one video media entity
$video = $row->_entity->get('field_pvideo')->entity;
// get multiple video media entities
$videos = $row->_entity->get('field_pvideo')->referencedEntities();
Then in Twig for one video:
{{ programme.video.field_media_video_embed_field.value }}
or multiple videos:
{% for video in programme.videos %}
{{ video.field_media_video_embed_field.value }}
{% endfor %}
Correct answer by 4k4 on December 12, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP