-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathposts.php
72 lines (51 loc) · 2.08 KB
/
posts.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/*
Author: Nathan Brettell
Digital Media Project
Gamification
*/
include('header.php');
?>
<div id="main">
<div id="content">
<?php include('category_menu.php'); ?>
<article id="post-directory">
<div class="new_post"><a href="#" class="button"> + Create new post </a></div>
<?php $posts = $g->get_posts();
//echo print_r($posts, true);
foreach($posts as $post) {
//echo print_r($post, true);
$g->debug();
$category = $g->post_category($post['post_id']);
//echo 'category ' . print_r($category, true);
$post_date = $post['post_date'];
$postDate = date('l j F o', strtotime($post_date));
if($category) {
foreach($category as $cat) {
//echo 'category ' . print_r($cat, true);
//echo "<h1><a href='post.php?id=".$post['post_id'].">Post Title: " . $post['post_title'] . '</a></h1>';
echo "<div id='post-entry-".$post['post_id']."' class='post-entry'>";
echo "<h1 class='post-title'><a href=post/".$post['post_slug'].">" . $post['post_title'] . "</a></h1>";
echo "<span class='post_date'>" . $postDate . "</span>";
echo "<div class='post_category'> Posted in <a href=posts/category/" . $cat['category_slug'] . ">" . $cat['category_name'] . "</a></div>";
// limit to certain amount of words with elipsis (...)
echo "<p>" . $post['post_content'] . "</p>";
echo "</div>";
}
}
else
{
//echo "<h1><a href='post.php?id=".$post['post_id'].">Post Title: " . $post['post_title'] . '</a></h1>';
echo "<div id='post-entry-".$post['post_id']." class='post-entry'>";
echo "<h1 class='post-title'><a href=post/".$post['post_slug'].">" . $post['post_title'] . "</a></h1>";
echo "<span class='post_date'>" . $postDate . "</span>";
echo "<div class='post_category'> No Category </div>";
echo "<p>" . $post['post_content'] . "</p>";
echo "</div>";
}
}
?>
</article>
</div>
</div>
<?php include('footer.html'); ?>