Created
July 27, 2012 09:14
-
-
Save marcelotten/3187017 to your computer and use it in GitHub Desktop.
Kirby iTunes-Feed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// get any list of items | |
// in this case we get all visible children of the blog section, | |
// flip them to get them in reverse order and make sure we only get the last 10 | |
$items = $pages->find($page->podcast())->children()->visible()->flip()->limit(25); | |
$podcast = $pages->find($page->podcast()); | |
// defaults | |
if(!isset($descriptionExcerpt)) $descriptionExcerpt = true; | |
// send the right header | |
header('Content-type: text/xml; charset="utf-8"'); | |
// echo the doctype | |
echo '<?xml version="1.0" encoding="utf-8"?>'; | |
?> | |
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0"> | |
<channel> | |
<title><?php echo xml($podcast->title()); ?></title> | |
<link><?php echo xml($podcast->url()); ?></link> | |
<language>de-de</language> | |
<copyright><?php echo xml($podcast->copyright()) ?></copyright> | |
<itunes:subtitle><?php echo xml($podcast->subtitle()); ?></itunes:subtitle> | |
<itunes:author><?php echo xml($podcast->author()) ?></itunes:author> | |
<itunes:summary><?php echo xml($podcast->summary()) ?></itunes:summary> | |
<description><?php echo xml($podcast->description()) ?></description> | |
<itunes:owner> | |
<itunes:name><?php echo xml($podcast->ownername()) ?></itunes:name> | |
<itunes:email><?php echo xml($podcast->owneremail()) ?></itunes:email> | |
</itunes:owner> | |
<itunes:category text="Technology"> | |
<itunes:category text="Gadgets"/> | |
</itunes:category> | |
<itunes:image href="<?php echo $podcast->images()->first()->url(); ?>" /> | |
<image> | |
<url><?php echo xml($podcast->images()->first()->url()); ?></url> | |
<title><?php echo xml($podcast->title()); ?></title> | |
<link><?php echo xml($podcast->url()); ?></link> | |
<width>300</width> | |
<height>300</height> | |
</image> | |
<?php foreach($items as $item): ?> | |
<?php $topics = $item->children(); ?> | |
<item> | |
<title><?php echo xml($item->title()) ?></title> | |
<link><?php echo xml($item->url()) ?></link> | |
<pubDate><?php echo xml(strftime('%a, %d %b %Y %R %Z', $item->date())) ?></pubDate> | |
<description><![CDATA[<?php | |
echo kirbytext($item->summary()); | |
foreach ($topics as $topic) { | |
echo '<h3>' . $topic->title() . '</h3>'; | |
echo kirbytext($topic->text()); | |
echo kirbytext($topic->links()); | |
} | |
echo '<p><a href="' . $item->url() . '#disqus_thread">Jetzt diese Folge kommentieren</a></p>'; | |
?>]]></description> | |
<itunes:author><?php echo xml($podcast->author()) ?></itunes:author> | |
<itunes:subtitle><?php echo xml($item->subtitle()); ?></itunes:subtitle> | |
<itunes:summary><?php echo xml($item->summary()) ?></itunes:summary> | |
<itunes:image href="<?php echo $item->images()->first()->url() ?>" /> | |
<enclosure url="<?php echo xml($item->file()) ?>.mp3?feed" length="<?php echo $item->length() ?>" type="audio/mpeg" /> | |
<guid><?php echo xml($item->file()) ?>.mp3?feed</guid> | |
<itunes:duration><?php echo xml($item->duration()) ?></itunes:duration> | |
<itunes:keywords><?php echo xml($item->keywords()) ?></itunes:keywords> | |
</item> | |
<?php endforeach ?> | |
</channel> | |
</rss> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment