Added ability to filter search by topic.
This commit is contained in:
parent
e1cb500f99
commit
6b2bfb726f
3 changed files with 15 additions and 4 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
20250210
|
||||
20250210.1
|
||||
|
|
|
@ -33,6 +33,11 @@ Template::addFunction('search_merge_query', function($attrs) use (&$searchQueryE
|
|||
elseif(!empty($searchQueryEvaluated['after']))
|
||||
$existing[] = 'after:' . $searchQueryEvaluated['after'];
|
||||
|
||||
if(!empty($attrs['topic']))
|
||||
$existing[] = 'topic:' . $attrs['topic'];
|
||||
elseif(!empty($searchQueryEvaluated['topic']))
|
||||
$existing[] = 'topic:' . $searchQueryEvaluated['topic'];
|
||||
|
||||
$existing = array_merge($existing, array_unique(array_merge(
|
||||
$searchQueryEvaluated['query'],
|
||||
empty($attrs['query']) ? [] : explode(' ', $attrs['query'])
|
||||
|
@ -41,7 +46,7 @@ Template::addFunction('search_merge_query', function($attrs) use (&$searchQueryE
|
|||
return implode(' ', $existing);
|
||||
});
|
||||
if(!empty($searchQuery)) {
|
||||
$searchQueryAttributes = ['type', 'author', 'after'];
|
||||
$searchQueryAttributes = ['type', 'author', 'after', 'topic'];
|
||||
$searchQueryParts = explode(' ', $searchQuery);
|
||||
foreach($searchQueryParts as $queryPart) {
|
||||
$queryPart = trim($queryPart);
|
||||
|
@ -141,8 +146,10 @@ if(!empty($searchQuery)) {
|
|||
else
|
||||
$newsCategoryInfos[$categoryId] = $categoryInfo = $msz->news->getCategory(postInfo: $postInfo);
|
||||
|
||||
$commentsCount = $postInfo->commentsSectionId !== null
|
||||
? $msz->comments->countPosts(categoryInfo: $postInfo->commentsSectionId, deleted: false) : 0;
|
||||
$commentsCount = $msz->commentsCtx->posts->countPosts(
|
||||
categoryName: $postInfo->commentsCategoryName,
|
||||
deleted: false,
|
||||
);
|
||||
|
||||
$newsPosts[] = [
|
||||
'post' => $postInfo,
|
||||
|
|
|
@ -94,6 +94,7 @@ class ForumPostsData {
|
|||
&& $searchQuery['type'] !== 'forum:post')
|
||||
return [];
|
||||
|
||||
$topicInfo = null;
|
||||
$userInfo = null;
|
||||
$deleted = false;
|
||||
$pagination = null;
|
||||
|
@ -101,6 +102,9 @@ class ForumPostsData {
|
|||
$afterPostInfo = null;
|
||||
$newerThanDays = null;
|
||||
|
||||
if(!empty($searchQuery['topic']))
|
||||
$topicInfo = $searchQuery['topic'];
|
||||
|
||||
if(!empty($searchQuery['author']))
|
||||
$userInfo = $searchQuery['author'];
|
||||
|
||||
|
|
Loading…
Reference in a new issue