Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added news column

  • Loading branch information...
commit 395e1c1a0656dff54c000e0209dc5d657e67cf4e 1 parent 85afdab
@katzgrau authored
View
2  application/config/autoload.php
@@ -109,7 +109,7 @@
|
*/
-$autoload['model'] = array();
+$autoload['model'] = array('News');
/* End of file autoload.php */
View
23 application/models/news.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * The file contains a model for dealing with news links
+ */
+
+/**
+ * This model represents a news link
+ */
+class News extends CI_Model {
+
+ /**
+ * Get recent news links
+ * @param int $n Number of news links to retrieve
+ * @return array[News]
+ */
+ public static function getRecent($n = 5) {
+ $CI = get_instance();
+ $CI->db->from('news');
+ $CI->db->order_by('posted DESC');
+ $CI->db->limit(5);
+ return $CI->db->get()->result('News');
+ }
+}
View
38 application/views/global/_left_column.php
@@ -33,44 +33,22 @@
<!-- End Twitter -->
- <?php if (isset($official_sparks)): ?>
+ <?php if ($items = News::getRecent()): ?>
<div class="info-box clearfix">
- <h2>Official Sparks</h2>
+ <h2>Spark News</h2>
<ul>
- <?php foreach ($official_sparks as $spark): ?>
+ <?php foreach ($items as $item): ?>
<li class="clearfix">
- <a style="font-size:16px;" href="<?php echo base_url(); ?>packages/<?php echo $spark->name; ?>/versions/HEAD/show"><img src="<?php echo Gravatar_helper::from_email($spark->email, null, 40); ?>" /></a>
<p class="no-margin">
- <a style="font-size:16px;" href="<?php echo base_url(); ?>packages/<?php echo $spark->name; ?>/versions/HEAD/show"><?php echo $spark->name; ?></a><br />
- by: <a href="<?php echo base_url(); ?>contributors/<?php echo $spark->username; ?>/profile"><?php echo $spark->username; ?></a>
+ <a style="font-size:16px;" href="<?php echo $item->url ?>"><?php echo $item->title ?></a><br />
+ <em><?php echo date('F j, Y', strtotime($item->posted)); ?></em><br />
+ from: <a href=""><?php echo parse_url($item->url, PHP_URL_HOST) ?></a>
</p>
- <br class="clear" />
- <p class="no-margin"><em><?php echo $spark->summary; ?></em></p>
</li>
<?php endforeach; ?>
- <li class="last"><a href="<?php echo base_url(); ?>packages/browse/official">View All Official Sparks</a></li>
+ <!-- <li class="last"><a href="<?php echo base_url(); ?>packages/browse/official">View All Official Sparks</a></li> -->
</ul>
</div>
<?php endif; ?>
-
- <?php if (isset($featured_sparks)): ?>
- <div class="info-box clearfix">
- <h2>Featured Sparks</h2>
- <ul>
- <?php foreach ($featured_sparks as $spark): ?>
- <li class="clearfix">
- <a style="font-size:16px;" href="<?php echo base_url(); ?>packages/<?php echo $spark->name; ?>/versions/HEAD/show"><img src="<?php echo Gravatar_helper::from_email($spark->email, null, 40); ?>" /></a>
- <p class="no-margin">
- <a style="font-size:16px;" href="<?php echo base_url(); ?>packages/<?php echo $spark->name; ?>/versions/HEAD/show"><?php echo $spark->name; ?></a><br />
- by: <a href="<?php echo base_url(); ?>contributors/<?php echo $spark->username; ?>/profile"><?php echo $spark->username; ?></a>
- </p>
- <br class="clear" />
- <p class="no-margin"><em><?php echo $spark->summary; ?></em></p>
- </li>
- <?php endforeach; ?>
- <li class="last"><a href="<?php echo base_url(); ?>packages/browse/featured">View All Featured Sparks</a></li>
- </ul>
- </div>
- <?php endif; ?>
-
+
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.