Back

Display Link/Description of Latest YouTube Video

Description

This code displays the latest YouTube video posted to any account. Because the YouTube RSS feed makes extensive use of tables and inline styles, we strip those out before displaying.

Code

${esc.hash}set(${esc.dollar}rssTotal = 1)

${esc.hash}${esc.hash} Replace "OklahomaChristian" with your own YouTube user name
${esc.hash}pullRSSFeed("http://gdata.youtube.com/feeds/base/users/OklahomaChristian/uploads?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile3")
${esc.hash}foreach(${esc.dollar}content in ${esc.dollar}list)
	<h3><a href="${esc.dollar}!content.link">${esc.dollar}!content.title</a></h3>
	${esc.hash}set(${esc.dollar}content.description = ${esc.dollar}content.description.replaceAll('(<\/?table[^>]*>)|(<\/?tbody[^>]*>)|(<\/?tr[^>]*>)|(<\/?td[^>]*>)|(style="[^"]*")',''))
	<p>${esc.dollar}!content.description</p>
${esc.hash}end

Have you created code you'd like to share with the dotCMS community?

Share your code Become a Contributor