-
-
Save MoondaysMedia/ba516d3e3bc63527d1a2a14f3f8bb277 to your computer and use it in GitHub Desktop.
Speaker List Cache Generation
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 | |
// this will read in all the speakers, sort them by date, then store in a file for use later | |
$speakerList = [ | |
'speaker-file', | |
]; | |
$speakers_all = []; | |
foreach($speakerList as $speaker) { | |
$speakers_all[$speaker] = include_once("./speakers/{$speaker}.php"); | |
$speakers_all[$speaker]['bullet-points'] = text2bullets($speakers_all[$speaker]['bullet-points']); | |
} | |
// sort speakers by date/time | |
foreach($speakers_all as $slug => $speaker) { | |
$timeslot[$slug] = $speaker['datetime']; | |
} | |
array_multisort($timeslot, SORT_ASC, $speakers_all); | |
file_put_contents(__DIR__.'/_speaker_list.txt', json_encode($speakers_all)); | |
echo "<h1>".count($speakers_all)." Speakers Cached</h1>"; | |
function text2bullets($text) { | |
$lines = preg_split("/\r\n|\n|\r/", $text); | |
foreach($lines as $key => $line){ | |
$lines[$key] = '<li>'.$line.'</li>'; | |
} | |
return implode(PHP_EOL, $lines); | |
} |
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 | |
// this is data needed for each speaker | |
return [ | |
'title' => 'xxx', | |
'datetime' => '2017-12-09 07:00:00', | |
'track' => 'track_1', | |
'video' => '', | |
'bullet-points' => <<<EOQ | |
EOQ | |
, | |
'description' => '', | |
'bonus_offer' => '', | |
'bonus_url' => '', | |
'bonus_desc' => '', | |
'name' => 'xxx', | |
'site_name' => '', | |
'site_url' => '', | |
'bio' => <<<EOQ | |
EOQ | |
]; |
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 | |
// this is a portion of the file included on every page | |
$speakerList = file_get_contents(__DIR__.'/_speaker_list.txt'); | |
if (empty($speakerList)) { | |
die("<h1>Must Build Speaker Cache"); | |
} | |
$speakers_all = json_decode($speakerList, true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment