Guitar Gathering Posted January 3, 2018 Posted January 3, 2018 Hey guys, I'd like to have a block on my forum in the side column that shows a feed from my YouTube channel - similar to a Facebook or Twitter feed. Just a small block like the member statistics type of block that can be added to the front look of the forum. Is there anything like this? Thanks for any help you can offer.
Nathan Explosion Posted January 3, 2018 Posted January 3, 2018 Got Pages? Create a custom block, with Manual PHP as the content editor type Locate your channel ID Add the following code to the block: $rss = simplexml_load_file('https://www.youtube.com/feeds/videos.xml?channel_id=YOURCHANNELID'); echo '<h1>'. $rss->title . '</h1>'; foreach ($rss->entry as $item) { echo '<a href="'.$item->link['href'].'">'.$item->title.'</a><br>'; } Save the block Drag the custom block in to position You now have the basics in place and can go from there. Not got Pages? Use this plugin instead:
Nathan Explosion Posted January 3, 2018 Posted January 3, 2018 The following will give you the basics for the items you requested here (obviously, replace the channel id I'm using in the code): $rss = simplexml_load_file('https://www.youtube.com/feeds/videos.xml?channel_id=UCoxg3Kml41wE3IPq-PC-LQw'); echo '<h1>'. $rss->title . '</h1>'; $count = 1; foreach ($rss->entry as $item) { if($count <= 5) { $videoid = str_replace('yt:video:','',$item->id); echo '<a href="'.$item->link['href'].'"><img src="https://i1.ytimg.com/vi/'.$videoid.'/2.jpg"></a><br>'; $count++; } else { break; } } echo '<a href="http://www.youtube.com/channel/UCoxg3Kml41wE3IPq-PC-LQw?sub_confirmation=1">Subscribe<a>'; Result:
Guitar Gathering Posted January 3, 2018 Author Posted January 3, 2018 Thanks. I tried it and it works. Nothing fancy but it works. Thanks for your help. I'm surprised that there isn't a ready made formatted plugin available for this. Seems like this would be a common functionality needed, just like the Facebook and Twitter Feed widgets.
opentype Posted January 3, 2018 Posted January 3, 2018 I have a look at it. If the data is so easy to load, I can turn it into a nice widget template with settings.
Nathan Explosion Posted January 6, 2018 Posted January 6, 2018 4 hours ago, opentype said: Getting there … ...and then some. Great work on this one!
AnonymousDev Posted January 29, 2018 Posted January 29, 2018 On 1/7/2018 at 1:28 AM, opentype said: Getting there … Very cool!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.