Homepage Featured Events Display Using DOM

The featured events on the Mason Law homepage is pulled from the master calendar’s RSS. To get the dates and times separated from the titles, accessing the DOM is needed. The following codes, which requires jQuery, make the magic happened: $(‘.rssItemLink’).each( function(){ $this = $(this); $this. html(‘<em>’ + $this. html(). replace(/((\d{1,2}\/){2}\d{2,4}\s*[0-9]{1,2}:[0-9]{1,2}\s*[apAP][mM]\s*to\s*[0-9]{1,2}:[0-9]{1,2}\s*[apAP][mM])/, ‘</em><b>$1</b>’ ) ); } );

Simple RSS Parser With lastRSS

LastRSS makes displaying RSS feed easy. Here’s an example: <?php // include lastRSS include “./lastRSS.php”; // Create lastRSS object $rss = new lastRSS; // Set cache dir and cache time limit (1200 seconds) // (don’t forget to chmod cahce dir to 777 to allow writing) $rss->cache_dir = ‘./temp’; $rss->cache_time = 1200; // Try to load and parse RSS file if ($rs = $rss->get(‘http://www.law.gmu.edu/rss/news_all’)) { // Show website logo (if presented) if ($rs[image_url] != ”) { echo “<a href=\”$rs[image_link]\”><img src=\”$rs[image_url]\” alt=\”$rs[image_title]\”  /></a>\n”; } // Show clickable website title echo “<h1><a href=\”$rs[link]\”>$rs[title]</a></h1>\n”; // Show website description echo “<p>$rs[description]</p>\n”; // Show last published articles (title, link, description) echo “<ul>\n”; foreach($rs[‘items’] as $item) { echo “\t<li><a href=\”$item[link]\”>”.$item[‘title’].”</a>”.$item[‘description’].”</li>\n”; } echo “</ul>\n”; } else { echo “Error: It’s not possible to reach RSS file…\n”; } ?>