Add Video thumbnail to Custom Page List?

Permalink
How to add an video thumbnail to custom page list which is an news feed and play the video from the thumbnail in the same page?

View Replies:
Responsive replied on at Permalink Reply
Responsive
did you ever get a reply on this ?
MrKDilkington replied on at Permalink Reply
MrKDilkington
@mohammedfaqruddin
@Responsive

If I understand the question correctly, I believe this could be done using a page text attribute. This would depend on the video though. If it was a web video from Vimeo, YouTube, etc., then the URL of the video would be the page attribute. This attribute would be used to display the thumbnail in the Page List block custom template. If the video was a file, you could likely use the file attribute.
Responsive replied on at Permalink Reply
Responsive
Hi MrK
Thanks, I managed to get it working as below but also wanted to ask how we get values from Blocks in the page.
$video = $page->getAttribute('video');
$url = $video;
$videolink = (parse_url($url, PHP_URL_PATH));
<iframe width="480" height="360" src="https://www.youtube.com/embed<?php echo $videolink?>?rel=0&controls=0&autohide=2&modestbranding=1" frameborder="0" allowfullscreen></iframe>
MrKDilkington replied on at Permalink Reply
MrKDilkington
@Responsive

You can try this:
// $page is the current page object in the Page List $pages loop
// - get all the blocks in the "Main" area of the current page
$pageBlocks = $page->getBlocks('Main');
// loop through all the blocks
foreach ($pageBlocks as $pageBlock) {
    // when the current block has the block handle of "youtube"
    // - get that block instance
    // - with the block instance, you can get the video URL using the "videoURL" property
    if ($pageBlock->btHandle == 'youtube') {
        $blockInstance = $pageBlock->getInstance();
        $videoURL = $blockInstance->videoURL;
        echo $videoURL;
    }
}