Tos Web Developer provides insights, tutorials, and advice around topics including content strategy, design, Drupal Development, Drupal Custom Module Development, Drupal 8 Custom themes, PHP, Server, Twig, and more



I have content type in Drupal 8 Project that content type I have use paragraph field as an entity reference. Using this paragraph field I have to print slider on a node in Drupal 8.

Step 1:- Create Paragraph type e.g YouTube Image Link and Thumbnail Image for the youtube video.

Step 2: - This Paragraph Type you have to use in your content as the entity reference as multiple fields.

Step 3: - Then you have to add a node in this content type. Then you can show on node-link and image print this link and image have to convert in the slider for that you have to create node.twig.html file.

Step 4: - In This node.twig.html you have to print single-single field value following will help you to how to print value and create a slider.


 <div class="slider rightvideo">   
 {% for key,value in node.field_youtube_video_related_vide %}  
 {% set data = node.field_youtube_video_related_vide[key] %}  
 {% set datavideo = data.entity.field_yutube_video_link.value %}  
 {% set image_uri = data.entity.field_video_image.entity.uri.value %}  
 {% set youtubevideo = datavideo[0].uri|split('=') %}  
 <div class="videoPlay" data-toggle="modal" data-target="#youtubeModal" data-src="https://www.youtube.com/embed/{{youtubevideo[1]}}">  
 <img src="{{ file_url(image_uri) }}" alt="slider">  
 </div>  
 {% endfor %}   
 </div>  

Using Above code you can show slider in drupal 8 HTML.

No comments:

Post a Comment

| Designed And Blog Post by www.toswebdeveloper.com