Browse Source

Added recent news

pull/24/head
Teknikode 4 years ago
parent
commit
d184a8e0e9
1 changed files with 56 additions and 1 deletions
  1. 56
    1
      home/main.php

+ 56
- 1
home/main.php View File

@@ -14,6 +14,61 @@
<br />
<div class="container">
<div class="col-sm-4">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title text-center">Recent News</h3>
</div>
<div class="panel-body">
<p>
<ul class="list-group">
<?php
$new_posts = $db->select('blog', "user_id=? ORDER BY date_posted DESC LIMIT 5", array(0));
$posts = array();
foreach ($new_posts as $post)
{
if (!is_array($post))
{
$posts = array($new_posts);
break;
}
array_push($posts, $post);
}
foreach ($posts as $post)
{
$post_id = $post['id'];
$author_id = $post['author_id'];
$author = $userTools->get($author_id);
$date = $post['date_posted'];
$title = $post['title'];
$tags = $post['tags'];
$post = $post['post'];
?>
<script>
var converter = new Markdown.getSanitizingConverter();
// Title Conversion
var old_post = $("#title_<?php echo $post_id; ?>").text();
var new_post = converter.makeHtml(old_post);
$("#title_<?php echo $post_id; ?>").html(new_post);
</script>
<li class="list-group-item">
<div class="row">
<div class="col-sm-12">
<div class="blog-post-sm">
<h2 class="blog-post-title-sm text-left"><a href="<?php echo get_page_url("blog", $CONF); ?>/<?php echo $author->username; ?>/<?php echo $post_id; ?>" id="title_<?php echo $post_id; ?>"><?php echo $title; ?></a></h2>
<p class="blog-post-meta-sm text-left text-muted">
Posted on <?php echo date("F d, Y",strtotime($date)); ?> by <a href="<?php echo get_page_url("home", $CONF); ?>/<?php echo $author->username; ?>"><?php echo $author->username; ?></a>
</p>
</div>
</div>
</div>
</li>
<?php
}
?>
</ul>
</p>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="panel panel-default">
@@ -77,7 +132,7 @@
<p>
<ul class="list-group">
<?php
$new_posts = $db->select('blog', "1=? ORDER BY date_posted DESC LIMIT 5", array(1));
$new_posts = $db->select('blog', "user_id!=? ORDER BY date_posted DESC LIMIT 5", array(0));
$posts = array();
foreach ($new_posts as $post)
{

Loading…
Cancel
Save