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

XF 2.0 XF:Post and XF:Thread Relation

AndrewSimm

Active member
#1
I am working on a news add-on and can't seem to figure out something basic.

This code below gets me this error: "LogicException: Unknown relation XF:Thread accessed on xf_post in src/XF/Mvc/Entity/Finder.php at line 630"

If I exclude XF:Thread then it works fine, but I need the thread title, so I got to have that in there. I've checked XF:post and it has a relation with XF:Thread

PHP:
$finder = \XF::finder('XF:Post');
$news = $finder->with('XF:Thread')->where('post_id',$post_id)->fetchOne();
So what did I do wrong?

edit: $post_id is 1 FWIW
 
Last edited:

Xon

Well-known member
#2
The relationship name is "Thread", which points to an entity called "XF:Thread".

aka the correct code should be;
Code:
$finder = \XF::finder('XF:Post');
$news = $finder->with('Thread')->where('post_id',$post_id)->fetchOne();