• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

get first post object within thread_view template

localhost8080

Well-known member
#1
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:

Snog

Well-known member
#2
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.
 

Snog

Well-known member
#7
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.