-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategory.php
147 lines (121 loc) · 3.61 KB
/
category.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
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
<?php
include("includes/header.php");
if(isset($_GET['category'])){
$category = $_GET['category'];
}
if(isset($_GET['post_type'])){
$post_type = $_GET['post_type'];
}
else{
$post_type = "";
}
if($category == ""){
header("Location: index.php");
exit();
}
else{
}
?>
<head>
<title><?php echo $category; ?> - Sta. Cruz, Laguna - Youth and Sports Develpment</title>
</head>
<div class="cover">
<div class="light-cover" style="text-transform: capitalize;"><p class="os-animation" data-animation="fadeInLeft"><?php echo $category; ?></p></div>
</div>
<div class="col-12 content">
<div class="row content-row justify-content-md-center">
<div class="col-12 col-md-9 content-info">
<div class="updates-body">
<div class="program-update-article">
<div class="posts_area"></div>
<br><br>
<div style="text-align: center;">
<button id="button" type="button" class="btn" style="background-color: rgba(189, 195, 199,0.3); padding: 0.6rem 2rem 0.6rem 2rem;">Load More Post</button>
<br>
<img id="loading" src="assets/images/icons/loading.gif">
</div>
</div>
</div>
</div>
<div class="col-12 col-md-3 content-side">
<div class="content-background">
<div class="sideinfo-content">
<h5>Latest Post</h5>
</div>
<div class="content-side-article">
<?php
echo $user_obj->loadPostPrograms_Services();
?>
</div>
<div class="sideinfo-content">
<h5>Upcoming Events</h5>
</div>
<div class="content-side-article">
<?php
echo $user_obj->loadPostPrograms_Latest_Events();
?>
</div>
<div class="sideinfo-content">
<h5>Categories</h5>
</div>
<div class="content-side-categories">
<a href="category.php?category=Health">Health</a>
<a href="category.php?category=Education">Education</a>
<a href="category.php?category=Sports">Sports</a>
<a href="category.php?category=Environment">Environment</a>
<a href="category.php?category=Contigency">Contigency</a>
<a href="category.php?category=Legislation">Legislation</a>
</div>
</div>
</div>
</div>
</div>
<?php
include("footer.php");
?>
<script>
$(document).ready(function() {
var category = '<?php echo $category; ?>';
$('#loading').show();
//Original ajax request for loading first posts
$.ajax({
url: "includes/handlers/ajax_load_category.php",
type: "POST",
data: "page=1&category=" + category,
cache:false,
success: function(data) {
$('#loading').hide();
$('.posts_area').html(data);
}
});
$(window).scroll(function() {
//$('#load_more').on("click", function() {
var height = $('.posts_area').height(); //Div containing posts
var scroll_top = $(this).scrollTop();
var page = $('.posts_area').find('.nextPage').val();
var noMorePosts = $('.posts_area').find('.noMorePosts').val();
document.getElementById('button').onclick = function() {
//if (noMorePosts == 'false') {
if (noMorePosts == 'true') {
$('#button').hide();
}
if (noMorePosts == 'false') {
$('#loading').show();
var ajaxReq = $.ajax({
url: "includes/handlers/ajax_load_category.php",
type: "POST",
data: "page=" + page + "&category=" + category,
cache:false,
success: function(response) {
$('.posts_area').find('.nextPage').remove(); //Removes current .nextpage
$('.posts_area').find('.noMorePosts').remove(); //Removes current .nextpage
$('#loading').hide();
$('.posts_area').append(response);
}
});
}
} //End if
return false;
}); //End (window).scroll(function())
});
</script>