Advertisement
Guest User

API v3 and TXP Calendar Events List Display

a guest
Nov 17th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. <h2 class="topper black">Upcoming Events:</h2>
  2.  
  3. <txp:variable name="CALPIPE"><txp:aks_cache id="CALPIPE"><txp:php>echo file_get_contents("YOURYAHOOPIPEJSONFEEDURL");</txp:php></txp:aks_cache></txp:variable>
  4. <txp:php>
  5. date_default_timezone_set('America/Chicago');
  6. $json = json_decode(parse('<txp:variable name="CALPIPE" />'), true);
  7. if(empty($json)) return;
  8. $oldate = '';
  9. foreach($json['value']['items'] as $i => $a) {
  10. $ts = strtotime($a['start']);
  11. $te = strtotime($a['end']);
  12. $title = htmlspecialchars($a['title']);
  13. $location = htmlspecialchars($a['location']);
  14. if($oldate != ($date = strftime('%a, %B %e:', $ts)))
  15. echo $i ? "</h3>\n<h3 class=\"event-date\">" : "<h3 class=\"event-date first\">", ($oldate = $date), "</h3>\n";
  16. if (empty($a['location']) && strftime('%I:%M%P', $ts) == '12:00am')
  17. echo '<strong>', $title , '</strong></div>';
  18. elseif (strftime('%I:%M%P', $ts) == '12:00am' && isset($a['location']))
  19. echo '<strong>', $title , '</strong><br />' , $location ,'<br /><br />';
  20. elseif (strftime('%I:%M%P', $ts) != '12:00am' && empty($a['location']))
  21. echo '<strong>', $title , '</strong><br />' , strftime('%l:%M%P', $ts) ,' - ' , strftime('%l:%M%P', $te) ,'<br /><br /></div>';
  22. else echo '<strong>', $title , '</strong><br />' , strftime('%l:%M%P', $ts) ,' - ' , strftime('%l:%M%P', $te) ,'<br />' , $location ,'<br /><br />';
  23. }
  24. </txp:php>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement