"Discussion preview" displaying latest post's content

attilakristo

New member
Hi fellow XenForo brothers/sisters :)

I'm total new to XenForo, just bought it a few weeks earlier.
May I ask if you know about a way to have the "discussion preview" display a preview of the latest/most fresh message instead of showing a part of the original (first) message of a thread?

By "discussion preview", I mean this text-box: http://cl.ly/2W0D2z0I2F3A3F0F3K2v
Based on my small research, it's an overlay. Right ?:)

Thanks in advance for any advice/thoughts.

Cheers,
Attila
 
This requires a code change:

library/XenForo/ControllerPublic/Thread.php

Replace the red code:

Rich (BB code):
	public function actionPreview()
	{
		$threadId = $this->_input->filterSingle('thread_id', XenForo_Input::UINT);

		$visitor = XenForo_Visitor::getInstance();

		$ftpHelper = $this->getHelper('ForumThreadPost');
		list($thread, $forum) = $ftpHelper->assertThreadValidAndViewable($threadId);

		$threadModel = $this->_getThreadModel();
		$postModel = $this->_getPostModel();

		if ($threadModel->isRedirect($thread))
		{
			return $this->responseView('XenForo_ViewPublic_Thread_Preview', '', array('post' => false));
		}

		$post = $postModel->getPostById($thread['first_post_id'], array(
			'join' => XenForo_Model_Post::FETCH_USER
		));
		if ($post['thread_id'] != $threadId || !$postModel->canViewPost($post, $thread, $forum))
		{
			return $this->responseView('XenForo_ViewPublic_Thread_Preview', '', array('post' => false));
		}

		$viewParams = array(
			'post' => $post,
			'thread' => $thread,
			'forum' => $forum
		);

		return $this->responseView('XenForo_ViewPublic_Thread_Preview', 'thread_list_item_preview', $viewParams);
	}

like so:

Rich (BB code):
	public function actionPreview()
	{
		$threadId = $this->_input->filterSingle('thread_id', XenForo_Input::UINT);

		$visitor = XenForo_Visitor::getInstance();

		$ftpHelper = $this->getHelper('ForumThreadPost');
		list($thread, $forum) = $ftpHelper->assertThreadValidAndViewable($threadId);

		$threadModel = $this->_getThreadModel();
		$postModel = $this->_getPostModel();

		if ($threadModel->isRedirect($thread))
		{
			return $this->responseView('XenForo_ViewPublic_Thread_Preview', '', array('post' => false));
		}

		$post = $postModel->getPostById($thread['last_post_id'], array(
			'join' => XenForo_Model_Post::FETCH_USER
		));
		if ($post['thread_id'] != $threadId || !$postModel->canViewPost($post, $thread, $forum))
		{
			return $this->responseView('XenForo_ViewPublic_Thread_Preview', '', array('post' => false));
		}

		$viewParams = array(
			'post' => $post,
			'thread' => $thread,
			'forum' => $forum
		);

		return $this->responseView('XenForo_ViewPublic_Thread_Preview', 'thread_list_item_preview', $viewParams);
	}

Keep in mind that file edits like this are overwritten when you upgrade. If you are familiar with the addon system then you can turn it into an addon.
 
How would you turn that into an add-on? You'd have to overwrite actionPreview correct and basically copy and paste the full function from above? Which then might not be compatible when you upgrade?
 
How would you turn that into an add-on? You'd have to overwrite actionPreview correct and basically copy and paste the full function from above? Which then might not be compatible when you upgrade?

Correct.

You could also override _getPostModel() in that controller to return a different model with a different getPostById() function, but that would affect all actions in the thread controller. It's probably better to just override actionPreview().

Sorry. Just thinking out loud.
 
Top Bottom