I develop an addon. Please tell me how I can pass a variable in my controller to the
My Controller:
Now, how to passing
Please help me!
thread_new_posts
template.My Controller:
PHP:
<?php
namespace HT\BnsForumImplement\Pub\Controller;
use XF\Mvc\ParameterBag;
use XF\Pub\Controller\Thread;
class Thaoluanrd extends Thread
{
public function actionThaoluanrd (ParameterBag $params)
{
$startEndDate = explode('-', $params->start_end_date);
$startDate = intval($startEndDate[0]);
if (!$startDate) {
return $this->notFound();
}
$endDate = !empty($startEndDate[1]) ? intval($startEndDate[1]) : null;
$this->assertNotEmbeddedImageRequest();
$thread = $this->assertViewableThread($params->thread_id, $this->getThreadViewExtraWith());
$threadTypeHandler = $thread->TypeHandler;
$overrideReply = $threadTypeHandler->overrideDisplay($thread, $this);
if ($overrideReply) {
return $overrideReply;
}
$threadRepo = $this->getThreadRepo();
$filters = [
['post_date', '>=', $startDate],
];
$page = 1;
$perPage = 10000;
$effectiveOrder = $this->filter('order', 'str');
$defaultOrder = $thread->TypeHandler->getDefaultPostListOrder($thread);
$availableSorts = $this->getAvailablePostListSorts($thread);
if (!$effectiveOrder || !isset($availableSorts[$effectiveOrder])) {
$effectiveOrder = $defaultOrder;
}
.......................................................................
if ($extraFetchIds) {
$extraFinder = $postRepo->findSpecificPostsForThreadView($thread, $extraFetchIds);
$this->applyPostListFilters($thread, $extraFinder, $filters, $extraFetchIds);
$thread->TypeHandler->adjustThreadPostListFinder(
$thread,
$extraFinder,
$page,
$this->request,
$extraFetchIds
);
$fetchPinnedPosts = $extraFinder->fetch();
$posts = $posts->merge($fetchPinnedPosts);
}
$threadPlugin = $this->plugin('XF:Thread');
$threadPlugin->fetchExtraContentForPostsFullView($posts, $thread);
$threadViewData = $threadTypeHandler->setupThreadViewData($thread, $posts, $extraFetchIds);
if ($isFirstPostPinned) {
$threadViewData->pinFirstPost();
}
if ($highlightPostIds) {
$threadViewData->addHighlightedPosts($highlightPostIds);
}
/** @var \XF\Repository\UserAlert $userAlertRepo */
$userAlertRepo = $this->repository('XF:UserAlert');
$userAlertRepo->markUserAlertsReadForContent(
'post',
array_keys($threadViewData->getFullyDisplayedPosts())
);
// note that this is the last shown post -- might not be date ordered any longer
$lastPost = $threadViewData->getLastPost();
if ($isSimpleDateDisplay) {
$threadRepo->markThreadReadByVisitor($thread, $lastPost->post_date);
}
$threadRepo->logThreadView($thread);
$overrideContext = [
'page' => $page,
'effectiveOrder' => $effectiveOrder,
'filters' => $filters
];
$pageNavFilters = $filters;
if ($effectiveOrder != $defaultOrder) {
$pageNavFilters['order'] = $effectiveOrder;
}
$creatableThreadTypes = $this->repository('XF:ThreadType')->getThreadTypeListData(
$thread->Forum->getCreatableThreadTypes(),
\XF\Repository\ThreadType::FILTER_SINGLE_CONVERTIBLE
);
$viewParams = [
'thread' => $thread,
'forum' => $thread->Forum,
'posts' => $threadViewData->getMainPosts(),
'firstPost' => $threadViewData->getFirstPost(),
'lastPost' => $lastPost,
'firstUnread' => $threadViewData->getFirstUnread(),
'isSimpleDateDisplay' => $isSimpleDateDisplay,
'creatableThreadTypes' => $creatableThreadTypes,
'endDate' => $endDate,
'isFirstPostPinned' => $isFirstPostPinned,
'pinnedPost' => $threadViewData->getPinnedFirstPost(),
'highlightedPosts' => $threadViewData->getHighlightedPosts(),
'templateOverrides' => $threadTypeHandler->getThreadViewTemplateOverrides($thread, $overrideContext),
'availableSorts' => $availableSorts,
'defaultOrder' => $defaultOrder,
'effectiveOrder' => $effectiveOrder,
'filters' => $filters,
'canInlineMod' => $threadViewData->canUseInlineModeration(),
'page' => $page,
'perPage' => $perPage,
'totalPosts' => $totalPosts,
'pageNavFilters' => $pageNavFilters,
'pageNavHash' => $isFirstPostPinned ? '>1:#posts' : '',
'attachmentData' => $this->getReplyAttachmentData($thread),
'pendingApproval' => $this->filter('pending_approval', 'bool')
];
list($viewClass, $viewTemplate) = $threadTypeHandler->getThreadViewAndTemplate($thread);
$viewParams = $threadTypeHandler->adjustThreadViewParams($thread, $viewParams, $this->request);
return $this->view($viewClass, 'thread_view_thaoluan_rd', $viewParams);
}
}
Now, how to passing
$endDate
to thread_new_posts
templatePlease help me!