2019-05-13 17:02:01 +00:00
|
|
|
<?php
|
2019-09-28 22:43:51 +00:00
|
|
|
namespace Misuzu;
|
|
|
|
|
2019-05-13 17:02:01 +00:00
|
|
|
require_once '../../misuzu.php';
|
|
|
|
|
|
|
|
$categoryId = !empty($_GET['c']) && is_string($_GET['c']) ? (int)$_GET['c'] : 0;
|
|
|
|
$category = news_category_get($categoryId, true);
|
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if(empty($category)) {
|
2019-05-13 17:02:01 +00:00
|
|
|
echo render_error(404);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-12-06 01:04:10 +00:00
|
|
|
$categoryPagination = new Pagination($category['posts_count'], 5);
|
2019-05-13 17:02:01 +00:00
|
|
|
|
2019-12-06 01:04:10 +00:00
|
|
|
if(!$categoryPagination->hasValidOffset()) {
|
2019-05-13 17:02:01 +00:00
|
|
|
echo render_error(404);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$posts = news_posts_get(
|
2019-12-06 01:04:10 +00:00
|
|
|
$categoryPagination->getOffset(),
|
|
|
|
$categoryPagination->getRange(),
|
2019-05-13 17:02:01 +00:00
|
|
|
$category['category_id']
|
|
|
|
);
|
|
|
|
|
|
|
|
$featured = news_posts_get(0, 10, $category['category_id'], true);
|
|
|
|
|
2019-12-04 18:16:22 +00:00
|
|
|
Template::render('news.category', [
|
2019-05-13 17:02:01 +00:00
|
|
|
'category' => $category,
|
|
|
|
'posts' => $posts,
|
|
|
|
'featured' => $featured,
|
|
|
|
'news_pagination' => $categoryPagination,
|
|
|
|
]);
|