YouTube playlist custom template

Permalink 1 user found helpful
I just made simple custom template of YouTube block that makes you easy to embed playlist onto your concrete5 sites.


====================
HOW TO INSTALL
====================

Create a blank text file at
/blocks/youtube/templates/playlist.php

Copy and paste the following code

<?php 
defined('C5_EXECUTE') or die("Access Denied.");
$url = parse_url($videoURL);
parse_str($url['query'], $query);
$c = Page::getCurrentPage();
$vWidth=640; // Video Width
$vHeight=390; // Video Height
$playlistID= str_replace('PL','',$query['list']);
if ($c->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('Content disabled in edit mode.'); ?></div>
   </div>
<?php  } else { ?>   
   <object width="<?php echo $vWidth;?>" height="<?php echo $vHeight;?>"><param name="movie" value="http://www.youtube.com/p/<?php echo $playlistID;?>?version=3&hl=<?php echo LOCALE;?>&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/p/<?php echo $playlistID;?>?version=3&hl=<?php echo LOCALE;?>&fs=1" type="application/x-shockwave-flash" width="<?php echo $vWidth;?>" height="<?php echo $vHeight;?>" allowscriptaccess="always" allowfullscreen="true"></embed></object>
<?php  } ?>


Change the number of $vWidth and $vHeight according to your site dimension, or you can create new custom template to change the dimension.

Save and upload onto your concrete5 site.


====================
HOW TO USE
====================

Use as YouTube block, but instead of using a regular video URL, you need to get the playlist URL, and apply "playlist" custom template.

The YouTube playlist URL looks like

http://www.youtube.com/playlist?list=PL297A125DC0A5A054...

Paste the URL onto the block.

Save

Click the block and "Custom Template"

Choose "Playlist"

Save

and Publish

Done

katz515
 
lsccom replied on at Permalink Reply
This no longer works, I believe youtube have taken away the legacy embed method which means that playlists can now only be embedded using an iframe!

Does anyone know how to adapt this code so that it supports the new method?