Create the ability to create blog pages and blog-posts.
This commit is contained in:
28
controllers/blog.php
Normal file
28
controllers/blog.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2026, Dreytac <dreytac@hobbyhome.net>
|
||||
*
|
||||
* This file is part of Kirby Blog.
|
||||
*
|
||||
* Kirby Blog is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* Kirby Blog is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with Kirby Blog. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
return function ($page) {
|
||||
$posts = new Pages();
|
||||
|
||||
if ($user = kirby()->user() and $user->role()->isAdmin()) {
|
||||
$posts = $page->childrenAndDrafts();
|
||||
} else {
|
||||
$posts = $page->children();
|
||||
}
|
||||
|
||||
$posts = $posts->sortBy("pinned", SORT_DESC, "updated", SORT_DESC);
|
||||
|
||||
$posts = $posts->paginate($page->postsPerPage()->toInt());
|
||||
|
||||
return compact("posts");
|
||||
};
|
||||
Reference in New Issue
Block a user