-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblog.php
More file actions
34 lines (27 loc) · 982 Bytes
/
blog.php
File metadata and controls
34 lines (27 loc) · 982 Bytes
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
<?php
require_once __DIR__ . '/../config.php';
require_once __DIR__ . '/../lib/handler.php';
/**
* this class uses the json backup from the old blog to maintain a "blog" on
* the site. This should be replaced
*/
class BlogController extends BaseHandler {
public function get($slug=false){
$json_file = file_get_contents(__DIR__ . '/model/blog_data.json');
$json = json_decode($json_file, true);
if($slug){
foreach($json['data']['posts'] as $post){
if(strtolower($post['slug']) == strtolower($slug)){
$content = $this->load('blog/post.html', [
'content' => $post['html'],
]);
return $this->page($content, 'DATCODE | '.$post['title']);
}
}
}
$content = $this->load('blog/list.html', [
'posts' => $json['data']['posts'],
]);
return $this->page($content);
}
}