Last active
October 24, 2015 20:52
-
-
Save chocolatkey/cd8da689288e0e62370d to your computer and use it in GitHub Desktop.
Foolslide RSS feed formatter for front page presentation (Foundation 5)
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 | |
//FoolSlide RSS Feed loader/formatter | |
//TODO: Use API instead of RSS feed | |
//Henry Stark 2015 | |
//ini_set('display_errors', 1); | |
//error_reporting(E_ALL ^ E_NOTICE); | |
$curl = curl_init(); | |
curl_setopt_array($curl, Array( | |
CURLOPT_URL => 'http://[INSERT FOOLSLIDE BASE URL]/feeds/rss/', | |
CURLOPT_USERAGENT => 'Chapter feed fetcher', | |
CURLOPT_TIMEOUT => 120, | |
CURLOPT_CONNECTTIMEOUT => 30, | |
CURLOPT_RETURNTRANSFER => TRUE, | |
CURLOPT_ENCODING => 'UTF-8' | |
)); | |
$data = curl_exec($curl); | |
curl_close($curl); | |
$xml = simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA); | |
$i = 0; | |
foreach ($xml->channel->item as $item) { | |
$link = str_replace("http:", "", $item->link); | |
$img = str_replace("http:", "", $item->description->img['src']); | |
echo '<hr />' . PHP_EOL; | |
if($i > 2){ | |
if($i == 3) { | |
echo '<div id="ffeed" class="ws">' . PHP_EOL; | |
} | |
echo '<h4><a href="' . $link . '">' . $item->title . '</a></h4>' . PHP_EOL; | |
echo '<p>Release date: ' . substr($item->pubDate, 0, 10) . '</p>' . PHP_EOL; | |
} else { | |
echo '<div class="row">' . PHP_EOL; | |
echo '<div class="large-3 medium-3 columns"><a class="th" href="' . $link . '"><img src="' . $img . '"></img></a></div>' . PHP_EOL; | |
echo '<div class="large-9 medium-9 columns"><h4><a href="' . $link . '">' . $item->title . '</a></h4>' . PHP_EOL; | |
echo '<p>Release date: ' . substr($item->pubDate, 0, 10) . '</p></div>' . PHP_EOL; | |
echo '</div>' . PHP_EOL; | |
} | |
$i++; | |
} | |
echo '<hr /><p>Looking for something older? Check <a href="[INSERT FOOLSLIDE BASE URL]/latest/2/">here</a></p>'; | |
if($i > 2) { | |
echo '</div>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment