get first post object within thread_view template

localhost8080

Well-known member
Hello,

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

Code:
$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

Code:
{$post.canLike}

as it is accessed at post template.

Someone knows about this?

Thank you.
 
Last edited:
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.
 
Hello again.

Someone knows how to get firstpost object of each thread in thread_list_item template easily?

Thank you.
 
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.
 
Back
Top Bottom