Fix empty posts error

This commit is contained in:
Gregorio Chiko Putra 2017-09-11 09:05:32 +07:00
parent 70a4c80143
commit aec3b73730

View File

@ -88,22 +88,22 @@ class Posts
$status = 'admin'; $status = 'admin';
} }
if (array_key_exists(0, $post)) { if ($post !== false) {
$posts = $post; if (array_key_exists(0, $post)) {
} else { $posts = $post;
$posts[] = $post; } else {
} $posts[] = $post;
}
// Replace \n or \r with <br /> // Replace \n or \r with <br />
for ($i=0; $i < count($posts); $i++) { for ($i=0; $i < count($posts); $i++) {
$posts[$i]['content'] = preg_replace('/\r\n/', '<br />', $posts[$i]['content']); $posts[$i]['content'] = preg_replace('/\r\n/', '<br />', $posts[$i]['content']);
}
} }
View::render($url, [ View::render($url, [
'posts' => $posts, 'posts' => $posts,
'status' => $status 'status' => $status
]); ]);
die();
} }
public function entry() public function entry()