misuzu/public/news/index.php

32 lines
574 B
PHP
Raw Normal View History

2019-05-13 17:44:08 +00:00
<?php
namespace Misuzu;
2019-05-13 17:44:08 +00:00
require_once '../../misuzu.php';
$categories = news_categories_get(0, 0, true);
$newsPagination = new Pagination(news_posts_count(null, true), 5, 'page');
2019-05-13 17:44:08 +00:00
if(!$newsPagination->hasValidOffset()) {
2019-05-13 17:44:08 +00:00
echo render_error(404);
return;
}
$posts = news_posts_get(
$newsPagination->getOffset(),
$newsPagination->getRange(),
2019-05-13 17:44:08 +00:00
null,
true
);
2019-06-10 17:04:53 +00:00
if(!$posts) {
2019-05-13 17:44:08 +00:00
echo render_error(404);
return;
}
Template::render('news.index', [
2019-05-13 17:44:08 +00:00
'categories' => $categories,
'posts' => $posts,
'news_pagination' => $newsPagination,
]);