News but everything is a function.
This commit is contained in:
parent
76cc71b0b8
commit
6d39c6e3c9
6 changed files with 263 additions and 150 deletions
|
@ -10,25 +10,7 @@ if (config_get_default(false, 'Site', 'embed_linked_data')) {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$news = db_query('
|
$news = news_posts_get(0, 5, null, true);
|
||||||
SELECT
|
|
||||||
p.`post_id`, p.`post_title`, p.`post_text`, p.`created_at`,
|
|
||||||
u.`user_id`, u.`username`,
|
|
||||||
COALESCE(u.`user_colour`, r.`role_colour`) as `user_colour`,
|
|
||||||
(
|
|
||||||
SELECT COUNT(`comment_id`)
|
|
||||||
FROM `msz_comments_posts`
|
|
||||||
WHERE `category_id` = `comment_section_id`
|
|
||||||
) as `post_comments`
|
|
||||||
FROM `msz_news_posts` as p
|
|
||||||
LEFT JOIN `msz_users` as u
|
|
||||||
ON p.`user_id` = u.`user_id`
|
|
||||||
LEFT JOIN `msz_roles` as r
|
|
||||||
ON u.`display_role` = r.`role_id`
|
|
||||||
WHERE p.`is_featured` = true
|
|
||||||
ORDER BY p.`created_at` DESC
|
|
||||||
LIMIT 5
|
|
||||||
')->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
$statistics = cache_get('index:stats:v1', function () {
|
$statistics = cache_get('index:stats:v1', function () {
|
||||||
return [
|
return [
|
||||||
|
|
29
public/manage/news.php
Normal file
29
public/manage/news.php
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
require_once '../../misuzu.php';
|
||||||
|
|
||||||
|
$newsPerms = perms_get_user(MSZ_PERMS_NEWS, user_session_current('user_id', 0));
|
||||||
|
|
||||||
|
switch ($_GET['v'] ?? null) {
|
||||||
|
case 'posts':
|
||||||
|
if (!perms_check($newsPerms, MSZ_PERM_NEWS_MANAGE_POSTS)) {
|
||||||
|
echo render_error(403);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo 'posts';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'categories':
|
||||||
|
if (!perms_check($newsPerms, MSZ_PERM_NEWS_MANAGE_CATEGORIES)) {
|
||||||
|
echo render_error(403);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$catTake = 15;
|
||||||
|
$catOffset = (int)($_GET['o'] ?? 0);
|
||||||
|
$cats = news_categories_get($catOffset, $catTake);
|
||||||
|
|
||||||
|
echo 'cats';
|
||||||
|
var_dump($cats);
|
||||||
|
break;
|
||||||
|
}
|
144
public/news.php
144
public/news.php
|
@ -12,25 +12,9 @@ tpl_vars([
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($postId !== null) {
|
if ($postId !== null) {
|
||||||
$getPost = db_prepare('
|
$post = news_post_get($postId);
|
||||||
SELECT
|
|
||||||
p.`post_id`, p.`post_title`, p.`post_text`, p.`created_at`, p.`comment_section_id`,
|
|
||||||
c.`category_id`, c.`category_name`,
|
|
||||||
u.`user_id`, u.`username`,
|
|
||||||
COALESCE(u.`user_colour`, r.`role_colour`) as `user_colour`
|
|
||||||
FROM `msz_news_posts` as p
|
|
||||||
LEFT JOIN `msz_news_categories` as c
|
|
||||||
ON p.`category_id` = c.`category_id`
|
|
||||||
LEFT JOIN `msz_users` as u
|
|
||||||
ON p.`user_id` = u.`user_id`
|
|
||||||
LEFT JOIN `msz_roles` as r
|
|
||||||
ON u.`display_role` = r.`role_id`
|
|
||||||
WHERE `post_id` = :post_id
|
|
||||||
');
|
|
||||||
$getPost->bindValue(':post_id', $postId, PDO::PARAM_INT);
|
|
||||||
$post = $getPost->execute() ? $getPost->fetch() : false;
|
|
||||||
|
|
||||||
if ($post === false) {
|
if (!$post) {
|
||||||
echo render_error(404);
|
echo render_error(404);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -40,14 +24,10 @@ if ($postId !== null) {
|
||||||
|
|
||||||
if ($commentsInfo) {
|
if ($commentsInfo) {
|
||||||
$post['comment_section_id'] = $commentsInfo['category_id'];
|
$post['comment_section_id'] = $commentsInfo['category_id'];
|
||||||
db_prepare('
|
news_post_comments_set(
|
||||||
UPDATE `msz_news_posts`
|
$post['post_id'],
|
||||||
SET `comment_section_id` = :comment_section_id
|
$post['comment_section_id'] = $commentsInfo['category_id']
|
||||||
WHERE `post_id` = :post_id
|
);
|
||||||
')->execute([
|
|
||||||
'comment_section_id' => $post['comment_section_id'],
|
|
||||||
'post_id' => $post['post_id'],
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$commentsInfo = comments_category_info($post['comment_section_id']);
|
$commentsInfo = comments_category_info($post['comment_section_id']);
|
||||||
|
@ -63,87 +43,27 @@ if ($postId !== null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($categoryId !== null) {
|
if ($categoryId !== null) {
|
||||||
$getCategory = db_prepare('
|
$category = news_categories_single($categoryId, true);
|
||||||
SELECT
|
|
||||||
c.`category_id`, c.`category_name`, c.`category_description`,
|
|
||||||
COUNT(p.`post_id`) AS `posts_count`
|
|
||||||
FROM `msz_news_categories` as c
|
|
||||||
LEFT JOIN `msz_news_posts` as p
|
|
||||||
ON c.`category_id` = p.`category_id`
|
|
||||||
WHERE c.`category_id` = :category_id
|
|
||||||
GROUP BY c.`category_id`
|
|
||||||
');
|
|
||||||
$getCategory->bindValue(':category_id', $categoryId, PDO::PARAM_INT);
|
|
||||||
$category = $getCategory->execute() ? $getCategory->fetch() : false;
|
|
||||||
|
|
||||||
if ($category === false || $postsOffset < 0 || $postsOffset >= $category['posts_count']) {
|
if (!$category || $postsOffset < 0 || $postsOffset >= $category['posts_count']) {
|
||||||
echo render_error(404);
|
echo render_error(404);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$getPosts = db_prepare('
|
$posts = news_posts_get(
|
||||||
SELECT
|
$postsOffset,
|
||||||
p.`post_id`, p.`post_title`, p.`post_text`, p.`created_at`,
|
$postsTake,
|
||||||
c.`category_id`, c.`category_name`,
|
$category['category_id']
|
||||||
u.`user_id`, u.`username`,
|
);
|
||||||
COALESCE(u.`user_colour`, r.`role_colour`) as `user_colour`,
|
|
||||||
(
|
|
||||||
SELECT COUNT(`comment_id`)
|
|
||||||
FROM `msz_comments_posts`
|
|
||||||
WHERE `category_id` = `comment_section_id`
|
|
||||||
) as `post_comments`
|
|
||||||
FROM `msz_news_posts` as p
|
|
||||||
LEFT JOIN `msz_news_categories` as c
|
|
||||||
ON p.`category_id` = c.`category_id`
|
|
||||||
LEFT JOIN `msz_users` as u
|
|
||||||
ON p.`user_id` = u.`user_id`
|
|
||||||
LEFT JOIN `msz_roles` as r
|
|
||||||
ON u.`display_role` = r.`role_id`
|
|
||||||
WHERE p.`category_id` = :category_id
|
|
||||||
ORDER BY `created_at` DESC
|
|
||||||
LIMIT :offset, :take
|
|
||||||
');
|
|
||||||
$getPosts->bindValue('offset', $postsOffset);
|
|
||||||
$getPosts->bindValue('take', $postsTake);
|
|
||||||
$getPosts->bindValue('category_id', $category['category_id'], PDO::PARAM_INT);
|
|
||||||
$posts = $getPosts->execute() ? $getPosts->fetchAll() : false;
|
|
||||||
|
|
||||||
$getFeatured = db_prepare('
|
$featured = news_posts_get(0, 10, $category['category_id'], true);
|
||||||
SELECT `post_id`, `post_title`
|
|
||||||
FROM `msz_news_posts`
|
|
||||||
WHERE `category_id` = :category_id
|
|
||||||
AND `is_featured` = true
|
|
||||||
ORDER BY `created_at` DESC
|
|
||||||
LIMIT 10
|
|
||||||
');
|
|
||||||
$getFeatured->bindValue('category_id', $category['category_id'], PDO::PARAM_INT);
|
|
||||||
$featured = $getFeatured->execute() ? $getFeatured->fetchAll() : [];
|
|
||||||
|
|
||||||
echo tpl_render('news.category', compact('category', 'posts', 'featured'));
|
echo tpl_render('news.category', compact('category', 'posts', 'featured'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$getCategories = db_prepare('
|
$categories = news_categories_get(0, 0, true);
|
||||||
SELECT
|
$postsCount = news_posts_count(null, true);
|
||||||
c.`category_id`, c.`category_name`,
|
|
||||||
COUNT(p.`post_id`) AS count
|
|
||||||
FROM `msz_news_categories` as c
|
|
||||||
LEFT JOIN `msz_news_posts` as p
|
|
||||||
ON c.`category_id` = p.`category_id`
|
|
||||||
WHERE `is_hidden` = false
|
|
||||||
GROUP BY c.`category_id`
|
|
||||||
HAVING count > 0
|
|
||||||
');
|
|
||||||
$categories = $getCategories->execute() ? $getCategories->fetchAll() : [];
|
|
||||||
|
|
||||||
$postsCount = (int)db_query('
|
|
||||||
SELECT COUNT(p.`post_id`) as `posts_count`
|
|
||||||
FROM `msz_news_posts` as p
|
|
||||||
LEFT JOIN `msz_news_categories` as c
|
|
||||||
ON p.`category_id` = c.`category_id`
|
|
||||||
WHERE p.`is_featured` = true
|
|
||||||
AND c.`is_hidden` = false
|
|
||||||
')->fetchColumn();
|
|
||||||
|
|
||||||
tpl_var('posts_count', $postsCount);
|
tpl_var('posts_count', $postsCount);
|
||||||
|
|
||||||
|
@ -152,32 +72,12 @@ if ($postsOffset < 0 || $postsOffset >= $postsCount) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$getPosts = db_prepare('
|
$posts = news_posts_get(
|
||||||
SELECT
|
$postsOffset,
|
||||||
p.`post_id`, p.`post_title`, p.`post_text`, p.`created_at`,
|
$postsTake,
|
||||||
c.`category_id`, c.`category_name`,
|
null,
|
||||||
u.`user_id`, u.`username`,
|
true
|
||||||
COALESCE(u.`user_colour`, r.`role_colour`) as `user_colour`,
|
);
|
||||||
(
|
|
||||||
SELECT COUNT(`comment_id`)
|
|
||||||
FROM `msz_comments_posts`
|
|
||||||
WHERE `category_id` = `comment_section_id`
|
|
||||||
) as `post_comments`
|
|
||||||
FROM `msz_news_posts` as p
|
|
||||||
LEFT JOIN `msz_news_categories` as c
|
|
||||||
ON p.`category_id` = c.`category_id`
|
|
||||||
LEFT JOIN `msz_users` as u
|
|
||||||
ON p.`user_id` = u.`user_id`
|
|
||||||
LEFT JOIN `msz_roles` as r
|
|
||||||
ON u.`display_role` = r.`role_id`
|
|
||||||
WHERE p.`is_featured` = true
|
|
||||||
AND c.`is_hidden` = false
|
|
||||||
ORDER BY p.`created_at` DESC
|
|
||||||
LIMIT :offset, :take
|
|
||||||
');
|
|
||||||
$getPosts->bindValue('offset', $postsOffset);
|
|
||||||
$getPosts->bindValue('take', $postsTake);
|
|
||||||
$posts = $getPosts->execute() ? $getPosts->fetchAll() : [];
|
|
||||||
|
|
||||||
if (!$posts) {
|
if (!$posts) {
|
||||||
echo render_error(404);
|
echo render_error(404);
|
||||||
|
|
|
@ -24,14 +24,7 @@ function geoip_cache(string $section, string $ipAddress, callable $value)
|
||||||
|
|
||||||
function geoip_country(string $ipAddress)
|
function geoip_country(string $ipAddress)
|
||||||
{
|
{
|
||||||
return geoip_cache('country', $ipAddress, function () {
|
return geoip_cache('country', $ipAddress, function () use ($ipAddress) {
|
||||||
return $GLOBALS[MSZ_GEOIP_INSTANCE_STORE]->country($ipAddress);
|
return $GLOBALS[MSZ_GEOIP_INSTANCE_STORE]->country($ipAddress);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function geoip_anonymous(string $ipAddress)
|
|
||||||
{
|
|
||||||
return geoip_cache('anonymous', $ipAddress, function () {
|
|
||||||
return $GLOBALS[MSZ_GEOIP_INSTANCE_STORE]->anonymousIp($ipAddress);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
209
src/news.php
209
src/news.php
|
@ -1,3 +1,212 @@
|
||||||
<?php
|
<?php
|
||||||
define('MSZ_PERM_NEWS_MANAGE_POSTS', 1);
|
define('MSZ_PERM_NEWS_MANAGE_POSTS', 1);
|
||||||
define('MSZ_PERM_NEWS_MANAGE_CATEGORIES', 1 << 1);
|
define('MSZ_PERM_NEWS_MANAGE_CATEGORIES', 1 << 1);
|
||||||
|
|
||||||
|
function news_categories_get(
|
||||||
|
int $offset,
|
||||||
|
int $take,
|
||||||
|
bool $includePostCount = false,
|
||||||
|
bool $featuredOnly = false,
|
||||||
|
bool $exposeScheduled = false,
|
||||||
|
bool $excludeDeleted = true
|
||||||
|
): array {
|
||||||
|
$getAll = $offset < 0 || $take < 1;
|
||||||
|
|
||||||
|
if ($includePostCount) {
|
||||||
|
$query = sprintf(
|
||||||
|
'
|
||||||
|
SELECT
|
||||||
|
`category_id`, `category_name`, `is_hidden`,
|
||||||
|
`created_at`, `updated_at`,
|
||||||
|
(
|
||||||
|
SELECT COUNT(`post_id`)
|
||||||
|
FROM `msz_news_posts`
|
||||||
|
WHERE %2$s %3$s %4$s
|
||||||
|
) as `posts_count`
|
||||||
|
FROM `msz_news_categories`
|
||||||
|
GROUP BY `category_id`
|
||||||
|
ORDER BY `category_id` DESC
|
||||||
|
%1$s
|
||||||
|
',
|
||||||
|
$getAll ? '' : 'LIMIT :offset, :take',
|
||||||
|
$featuredOnly ? '`is_featured`' : '1',
|
||||||
|
$exposeScheduled ? '' : 'AND `scheduled_for` < NOW()',
|
||||||
|
$excludeDeleted ? 'AND `deleted_at` IS NULL' : ''
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$query = sprintf('
|
||||||
|
SELECT
|
||||||
|
`category_id`, `category_name`, `is_hidden`,
|
||||||
|
`created_at`, `updated_at`
|
||||||
|
FROM `msz_news_categories`
|
||||||
|
ORDER BY `category_id` DESC
|
||||||
|
%s
|
||||||
|
', $getAll ? '' : 'LIMIT :offset, :take');
|
||||||
|
}
|
||||||
|
|
||||||
|
$getCats = db_prepare($query);
|
||||||
|
|
||||||
|
if (!$getAll) {
|
||||||
|
$getCats->bindValue('offset', $offset);
|
||||||
|
$getCats->bindValue('take', $take);
|
||||||
|
}
|
||||||
|
|
||||||
|
$cats = $getCats->execute() ? $getCats->fetchAll(PDO::FETCH_ASSOC) : false;
|
||||||
|
return $cats ? $cats : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function news_categories_single(
|
||||||
|
int $category,
|
||||||
|
bool $includePostCount = false,
|
||||||
|
bool $featuredOnly = false,
|
||||||
|
bool $exposeScheduled = false,
|
||||||
|
bool $excludeDeleted = true
|
||||||
|
): array {
|
||||||
|
if ($includePostCount) {
|
||||||
|
$query = sprintf(
|
||||||
|
'
|
||||||
|
SELECT
|
||||||
|
c.`category_id`, c.`category_name`, c.`category_description`,
|
||||||
|
COUNT(p.`post_id`) AS `posts_count`
|
||||||
|
FROM `msz_news_categories` as c
|
||||||
|
LEFT JOIN `msz_news_posts` as p
|
||||||
|
ON c.`category_id` = p.`category_id`
|
||||||
|
WHERE c.`category_id` = :category %1$s %2$s %3$s
|
||||||
|
GROUP BY c.`category_id`
|
||||||
|
',
|
||||||
|
$featuredOnly ? 'AND p.`is_featured` = 1' : '',
|
||||||
|
$exposeScheduled ? '' : 'AND p.`scheduled_for` < NOW()',
|
||||||
|
$excludeDeleted ? 'AND p.`deleted_at` IS NULL' : ''
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
c.`category_id`, c.`category_name`, c.`category_description`,
|
||||||
|
FROM `msz_news_categories` as c
|
||||||
|
WHERE c.`category_id` = :category
|
||||||
|
GROUP BY c.`category_id`
|
||||||
|
';
|
||||||
|
}
|
||||||
|
|
||||||
|
$getCategory = db_prepare($query);
|
||||||
|
$getCategory->bindValue('category', $category);
|
||||||
|
$category = $getCategory->execute() ? $getCategory->fetch(PDO::FETCH_ASSOC) : false;
|
||||||
|
return $category ? $category : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function news_posts_count(
|
||||||
|
?int $category = null,
|
||||||
|
bool $featuredOnly = false,
|
||||||
|
bool $exposeScheduled = false,
|
||||||
|
bool $excludeDeleted = true
|
||||||
|
): int {
|
||||||
|
$hasCategory= $category !== null;
|
||||||
|
|
||||||
|
$countPosts = db_prepare(sprintf(
|
||||||
|
'
|
||||||
|
SELECT COUNT(`post_id`)
|
||||||
|
FROM `msz_news_posts`
|
||||||
|
WHERE %1$s %2$s %3$s %4$s
|
||||||
|
',
|
||||||
|
$hasCategory ? '`category_id` = :category' : '1',
|
||||||
|
$featuredOnly ? 'AND `is_featured` = 1' : '',
|
||||||
|
$exposeScheduled ? '' : 'AND `scheduled_for` < NOW()',
|
||||||
|
$excludeDeleted ? 'AND `deleted_at` IS NULL' : ''
|
||||||
|
));
|
||||||
|
|
||||||
|
if ($hasCategory) {
|
||||||
|
$countPosts->bindValue('category', $category);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $countPosts->execute() ? (int)$countPosts->fetchColumn() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function news_posts_get(
|
||||||
|
int $offset,
|
||||||
|
int $take,
|
||||||
|
?int $category = null,
|
||||||
|
bool $featuredOnly = false,
|
||||||
|
bool $exposeScheduled = false,
|
||||||
|
bool $excludeDeleted = true
|
||||||
|
): array {
|
||||||
|
$getAll = $offset < 0 || $take < 1;
|
||||||
|
$hasCategory= $category !== null;
|
||||||
|
|
||||||
|
$getPosts = db_prepare(sprintf(
|
||||||
|
'
|
||||||
|
SELECT
|
||||||
|
p.`post_id`, p.`post_title`, p.`post_text`, p.`created_at`,
|
||||||
|
c.`category_id`, c.`category_name`,
|
||||||
|
u.`user_id`, u.`username`,
|
||||||
|
COALESCE(u.`user_colour`, r.`role_colour`) as `user_colour`,
|
||||||
|
(
|
||||||
|
SELECT COUNT(`comment_id`)
|
||||||
|
FROM `msz_comments_posts`
|
||||||
|
WHERE `category_id` = `comment_section_id`
|
||||||
|
) as `post_comments`
|
||||||
|
FROM `msz_news_posts` as p
|
||||||
|
LEFT JOIN `msz_news_categories` as c
|
||||||
|
ON p.`category_id` = c.`category_id`
|
||||||
|
LEFT JOIN `msz_users` as u
|
||||||
|
ON p.`user_id` = u.`user_id`
|
||||||
|
LEFT JOIN `msz_roles` as r
|
||||||
|
ON u.`display_role` = r.`role_id`
|
||||||
|
WHERE %5$s %2$s %3$s %4$s
|
||||||
|
ORDER BY p.`created_at` DESC
|
||||||
|
%1$s
|
||||||
|
',
|
||||||
|
$getAll ? '' : 'LIMIT :offset, :take',
|
||||||
|
$featuredOnly ? 'AND p.`is_featured` = 1' : '',
|
||||||
|
$exposeScheduled ? '' : 'AND p.`scheduled_for` < NOW()',
|
||||||
|
$excludeDeleted ? 'AND p.`deleted_at` IS NULL' : '',
|
||||||
|
$hasCategory ? 'p.`category_id` = :category' : '1'
|
||||||
|
));
|
||||||
|
|
||||||
|
if ($hasCategory) {
|
||||||
|
$getPosts->bindValue('category', $category);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$getAll) {
|
||||||
|
$getPosts->bindValue('take', $take);
|
||||||
|
$getPosts->bindValue('offset', $offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
$posts = $getPosts->execute() ? $getPosts->fetchAll(PDO::FETCH_ASSOC) : false;
|
||||||
|
return $posts ? $posts : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function news_post_comments_set(int $postId, int $sectionId): void
|
||||||
|
{
|
||||||
|
db_prepare('
|
||||||
|
UPDATE `msz_news_posts`
|
||||||
|
SET `comment_section_id` = :comment_section_id
|
||||||
|
WHERE `post_id` = :post_id
|
||||||
|
')->execute([
|
||||||
|
'comment_section_id' => $sectionId,
|
||||||
|
'post_id' => $postId,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function news_post_get(int $postId): array
|
||||||
|
{
|
||||||
|
$getPost = db_prepare('
|
||||||
|
SELECT
|
||||||
|
p.`post_id`, p.`post_title`, p.`post_text`, p.`created_at`, p.`comment_section_id`,
|
||||||
|
c.`category_id`, c.`category_name`,
|
||||||
|
u.`user_id`, u.`username`,
|
||||||
|
COALESCE(u.`user_colour`, r.`role_colour`) as `user_colour`
|
||||||
|
FROM `msz_news_posts` as p
|
||||||
|
LEFT JOIN `msz_news_categories` as c
|
||||||
|
ON p.`category_id` = c.`category_id`
|
||||||
|
LEFT JOIN `msz_users` as u
|
||||||
|
ON p.`user_id` = u.`user_id`
|
||||||
|
LEFT JOIN `msz_roles` as r
|
||||||
|
ON u.`display_role` = r.`role_id`
|
||||||
|
WHERE `post_id` = :post_id
|
||||||
|
');
|
||||||
|
|
||||||
|
$getPost->bindValue(':post_id', $postId);
|
||||||
|
$post = $getPost->execute() ? $getPost->fetch(PDO::FETCH_ASSOC) : false;
|
||||||
|
|
||||||
|
return $post ? $post : [];
|
||||||
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
{{ category.category_name }}
|
{{ category.category_name }}
|
||||||
</div>
|
</div>
|
||||||
<div class="news__list__value">
|
<div class="news__list__value">
|
||||||
{{ category.count }} post{{ category.count == 1 ? '' : 's' }}
|
{{ category.posts_count }} post{{ category.posts_count == 1 ? '' : 's' }}
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
Loading…
Add table
Reference in a new issue