get first post object within thread_view template


Well-known member

I need the object of the first posting of a thread.

All I have get gone is to get the flat array but not the populated object of the first posting by using

$postModel = XenForo_Model::create('XenForo_Model_Post');
$post = $postModel->getPostById($this->_params['thread']['first_post_id']);
at XenForo_ViewPublic_Thread_View

I would need the value of

as it is accessed at post template.

Someone knows about this?

Thank you.
Last edited:


Well-known member
If you need it in PHP, check the post model for XenForo, it has a built in function 'canLikePost'.

If you just need it in the thread_view template, $firstPost.canLike is already available in the template.


Well-known member
I don't think you can get the whole post by template calls in that template.

Take a look at library/XenForo/ControllerPublic/Threads.php actionPreview. It's a good example of how to look up the full post info.