misuzu/public/news/index.php

33 lines
633 B
PHP
Raw Normal View History

2019-05-13 19:44:08 +02:00
<?php
namespace Misuzu;
2019-05-13 19:44:08 +02:00
require_once '../../misuzu.php';
$categories = news_categories_get(0, 0, true);
$newsPagination = pagination_create(news_posts_count(null, true), 5);
$postsOffset = pagination_offset($newsPagination, pagination_param('page'));
2019-06-10 19:04:53 +02:00
if(!pagination_is_valid_offset($postsOffset)) {
2019-05-13 19:44:08 +02:00
echo render_error(404);
return;
}
$posts = news_posts_get(
$postsOffset,
$newsPagination['range'],
null,
true
);
2019-06-10 19:04:53 +02:00
if(!$posts) {
2019-05-13 19:44:08 +02:00
echo render_error(404);
return;
}
echo tpl_render('news.index', [
'categories' => $categories,
'posts' => $posts,
'news_pagination' => $newsPagination,
]);