Youtube Playlist Custom Template (as Iframe)
Permalink 2 users found helpful
Hello everyone! Here I'll give my code to put a custom template in the Youtube video block to be able to display playlist in your Concrete5 site. The only thing to remember is that this custom template only works in Iframe mode.
Let's get started.
First of all, you'll need to download the view.php file from
/concrete/blocks/youtube
Rename it as playlist.php
Open it and replace the code with this:
Save it and then upload the file in
/blocks/youtube/templates (create that folders if necessary).
---
Now, in your site, when creating a new Youtube video block, paste the Playlist link. The Playlist link looks like this:
http://www.youtube.com/playlist?list=PLE5SSuomwnmXeZUtpkpJsf1E7qb4O...
Remember to use Iframe method and save. Click the new block and select "Custom Template", choose "Playlist", Save and Publish.
Let's get started.
First of all, you'll need to download the view.php file from
/concrete/blocks/youtube
Rename it as playlist.php
Open it and replace the code with this:
<?php defined('C5_EXECUTE') or die("Access Denied."); $url = parse_url($videoURL); $pathParts = explode('/', rtrim($url['path'], '/')); $videoID = end($pathParts); if (isset($url['query'])) { parse_str($url['query'], $query); $videoID = (isset($query['list'])) ? $query['list'] : $videoID; } $vWidth = ($vWidth) ? $vWidth : 425; $vHeight = ($vHeight) ? $vHeight : 344; if (Page::getCurrentPage()->isEditMode()) { ?> <div class="ccm-edit-mode-disabled-item" style="width: <?php echo $vWidth; ?>px; height: <?php echo $vHeight; ?>px;"> <div style="padding:8px 0px; padding-top: <?php echo round($vHeight/2)-10; ?>px;"><?php echo t('YouTube Video disabled in edit mode.'); ?></div> </div>
Viewing 15 lines of 20 lines. View entire code block.
Save it and then upload the file in
/blocks/youtube/templates (create that folders if necessary).
---
Now, in your site, when creating a new Youtube video block, paste the Playlist link. The Playlist link looks like this:
http://www.youtube.com/playlist?list=PLE5SSuomwnmXeZUtpkpJsf1E7qb4O...
Remember to use Iframe method and save. Click the new block and select "Custom Template", choose "Playlist", Save and Publish.