svn: /pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/ News.tpl.php
[email protected] (Brett Bieber)
| Newsgroups | php.pear.cvs,php.pear.core |
|---|---|
| Message-ID | <[email protected]> |
saltybeagle Fri, 11 Jun 2010 15:10:36 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=300387
Log:
Hook up the pear blog to the news.
Changed paths:
U pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/News.tpl.php
Modified: pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/News.tpl.php
===================================================================
--- pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/News.tpl.php 2010-06-11 14:17:50 UTC (rev 300386)
+++ pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/News.tpl.php 2010-06-11 15:10:36 UTC (rev 300387)
@@ -1,6 +1,10 @@
<?php
// Set the title for the main template
$parent->context->page_title = 'News | pear2.php.net';
+$rss_feed = '/var/tmp/pear/rss_cache/pear-news.xml';
+if (file_exists($rss_feed)) {
+ $blog = simplexml_load_file($rss_feed);
+}
?>
<div id="recent">
@@ -11,10 +15,18 @@
</div>
<div id="news">
<h2>News</h2>
- <ul>
- <li><a href="#">PEAR channels on google code currently broken<span> – March 23, 2010</span></a></li>
- <li><a href="#">PEAR in March 2010<span> – March 19, 2010</span></a></li>
- <li><a href="#">Net_Traceroute and Net_Ping security advisory<span> – March 14, 2010</span></a></li>
- </ul>
+ <?php if (!empty($blog)) { ?>
+ <?php $n = 0; ?>
+ <ul>
+ <?php foreach ($blog->xpath('//item') as $node) { ?>
+ <?php if ($n++ >= 3) { continue; } ?>
+ <li><a href="<?php echo (string)$node->link; ?>"><?php echo (string)$node->title; ?><span> – <?php echo date('F j, Y', strtotime($node->pubDate)); ?></span></a></li>
+ <?php } ?>
+ </ul>
+ <?php } else { ?>
+ <p>Looks like we don't have an RSS feed. Try adding a cron job to fetch <a href="http://blog.pear.php.net/feed/">http://blog.pear.php.net/feed/</a> and put it in <?php print $rss_feed; ?></p>
+ <pre>wget --output-document=/var/tmp/pear/rss_cache/pear-news.xml http://blog.pear.php.net/feed/</pre>
+ <?php } ?>
</div>
+
<?php echo $savant->render(new \PEAR2\SimpleChannelFrontend\Categories(array('frontend'=>$parent->context->getRawObject()))); ?>