guiltar
Well-known member
Hey, Developers!
I'm writing threaded comments addon and trying to extend the method actionAddReply of class XenForo_ControllerPublic_Thread.
It has to return all the new posts via ajax request.
But there is a fixed limit of shown posts in engine: 3.
If the number of posts returned by model is more then 3, then the earliest post will be removed.
And there is no nice way to extend it without rewriting all the method.
So, please, do the var $limit controllable by extensions. For example, it can be taken from registry:
I'm writing threaded comments addon and trying to extend the method actionAddReply of class XenForo_ControllerPublic_Thread.
It has to return all the new posts via ajax request.
But there is a fixed limit of shown posts in engine: 3.
PHP:
public function actionAddReply()
{
....
// the max number of posts we want to fetch
$limit = 3;
$postFetchOptions = $this->_getPostFetchOptions($thread, $forum);
$postFetchOptions += array(
'limit' => ($limit + 1),
);
......
$posts = $postModel->getNewestPostsInThreadAfterDate(
$threadId, $lastDate, $postFetchOptions
);
// We fetched one more post than needed, if more than $limit posts were returned,
// we can show the 'there are more posts' notice
if (count($posts) > $limit)
{
....
// remove the extra post
array_pop($posts);
}
....
If the number of posts returned by model is more then 3, then the earliest post will be removed.
And there is no nice way to extend it without rewriting all the method.
So, please, do the var $limit controllable by extensions. For example, it can be taken from registry:
PHP:
$limit = XenForo_Application::get('options')->maxNewPostsByAjax
Upvote
1