-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcategory.php
More file actions
160 lines (111 loc) · 4.09 KB
/
category.php
File metadata and controls
160 lines (111 loc) · 4.09 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-db-connection.php");
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-functions.php");
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-header.php");
?>
<main>
<?php
$categoryId = isset($_GET['categoryId']) ? $_GET['categoryId'] : '';
$category = DB::getInstance()->selectValues("SELECT * FROM `categories` WHERE `category_id`='{$categoryId}'");
?>
<div class="card breadcrumb-card">
<div class="card-body breadcrumb-body">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<?= urlFull(); ?>" class="home-link"><i class="fas fa-home"></i></a></li>
<li class="breadcrumb-item active" aria-current="page"><?= seoFriendlyUrls($category['category_id'], getCategoryname($category['category_id']), true, false); ?></li>
</ol>
</nav>
</div>
</div>
<?php
if (isset($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = 1;
}
$max = (int)getValue("homepage_pagination");
$from = ($page * $max) - $max;
$posts = DB::getInstance()->select("
SELECT *
FROM `posts`
WHERE `post_category_id`='{$categoryId}'
AND `post_status`='published'
ORDER BY `post_date` DESC
LIMIT :from, :max_results",
[
'from' => [
'type' => PDO::PARAM_INT,
'value' => $from
],
'max_results' => [
'type' => PDO::PARAM_INT,
'value' => $max
]
]);
$total = DB::getInstance()->selectValue('SELECT count(*) FROM `posts`');
if (!count($posts)) {
stderr('There are <strong>no</strong> posts made in this category yet!');
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-footer.php");
exit;
}
?>
<?php
if (isset($_GET['categoryId'])) {
$params = [];
$pagination = [];
$params['categoryId'] = $_GET['categoryId'];
$pagination['categoryId'] = $_GET['categoryId'];
}
?>
<div class="row">
<!-- posts -->
<div class="col-md-<?= getValue("hide_all_sidebars") == 0 ? "12" : "9"; ?>">
<?php
$count = 0;
foreach($posts as $post) {
?>
<div class="card" style="box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);">
<div class="card-header" style="font-family: 'Helvetica Neue', sans-serif; font-size: 16px; text-transform: uppercase; text-align: center; background-color: transparent; padding: 1rem;">
<small><i class="fas fa-pencil-alt"></i> Posted on <strong><?= date("F j, Y", strtotime($post['post_date'])); ?></strong> by <strong><span class="text-success"><?= getPostersUsername($post['post_member_id']); ?></span></strong>.</small>
</div>
<div class="card-body">
<?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-post-structure.php"); ?>
</div>
<div class="card-footer mt-3" style="font-size: 14px; background-color: transparent;"><small><span class="float-end"><i class="fas fa-eye"></i><?= $post['post_views']; ?></span></small></div>
</div>
<?php } ?>
</div>
<?php if (getValue("hide_all_sidebars") != 0) { ?>
<!-- categories / sidebars -->
<div class="col-md-3">
<?php
if (!empty(getValue("about_us_header")) && !empty(getValue("about_us_text"))) {
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-about-us.php");
}
?>
<?php
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-sidebar-recent-posts.php");
?>
<?php
if (getValue("homepage_show_categories")) {
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-sidebar-categories.php");
}
?>
<?php
if (!empty(getValue("sidebar_cta_1_header")) && !empty(getValue("sidebar_cta_1_text"))) {
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-sidebar-cta-1.php");
}
?>
<?php
if (!empty(getValue("sidebar_cta_2_header")) && !empty(getValue("sidebar_cta_2_text"))) {
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-sidebar-cta-2.php");
}
?>
</div>
<?php } ?>
</div>
</main>
<?php
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-footer.php");
?>