Skip to content

Instantly share code, notes, and snippets.

@richsalvucci
Last active August 9, 2018 15:25
Show Gist options
  • Save richsalvucci/a0a1459f555cd9d706d41e430da63d38 to your computer and use it in GitHub Desktop.
Save richsalvucci/a0a1459f555cd9d706d41e430da63d38 to your computer and use it in GitHub Desktop.
PHP for Book King
<div id="rink-programsidebar" class="one-half column-last">
<div id="rink-todaysched">
<h2>Today's Schedule: </h2>
<?php
$customRSS = get_field('rss_feed_url');
$custRSSdecode = htmlspecialchars_decode($customRSS);
$ch = curl_init();
$timeout = 10;
curl_setopt($ch, CURLOPT_URL, $custRSSdecode);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt ($ch, CURLOPT_SSLVERSION, 6);
$html = curl_exec($ch);
curl_close($ch);
var_dump($custRSSdecode);
var_dump($html);
$rss = new DOMDocument();
$rss->load($html);
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
);
array_push($feed, $item);
}
// Get the count of how many are in the array
$max = sizeof($feed);
?>
<table id="FMCEvents">
<tbody id="FMCEvents_TBody">
<?php
// Limit is now not hard coded, will show everything coming from the feed.
$limit = $max;
for($x=0;$x<$limit;$x++) {
$title = $feed[$x]['title'];
$description = $feed[$x]['desc'];
?>
<tr>
<td class="sched-time"><?php echo $title; ?></td>
<td class="sched-event"><?php echo $description; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<a href="<?php the_field('full_schedule_url') ?>" class="office-button blue schedule"><span>View Full Schedule</span></a> <a href="<?php the_field('public_skating_schedule_link') ?>" class="office-button blue"><span>Public Skating Schedule</span></a>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment