fetch_threadinfo equivalent?

Jafo

Active member
If I have the ID of a thread, how would I go about fetching the info on it? Is this cached?
 
No, it is not cached.

There's not a whole lot of information here to know what you need or where you'll be using the code, but one way of accessing the thread info is:

PHP:
$threadModel = XenForo_Model::create('XenForo_Model_Thread');

$thread = $threadModel->getThreadById($threadId);
 
Thanks Chris. Well maybe I am going about this the wrong way then. I have a listener listening on the template_hook event. I am trying to get the threads reply_count value but I don't think this info is available in any of the arguments passed to the event, but maybe I am wrong? I obviously don't want to query thread info for each time a post in a thread is parsed.
 
I really need to know exactly what you want to achieve.

It may be that you have to query it if the reply_count value isn't available in that template hook. Without knowing what template hook, it's going to be difficult.

Also, template hooks are officially deprecated so you should be using the built in Template Modification system for templates; though, again, if the parameter isn't available to the template then maybe the template hook is more appropriate.

Unfortunately I can only speculate at this point.
 
Chris, thanks, this is the first I have used the Template Modification System so bear with me. :)

I would like to hook into the message template where currently the message_content hook is located. Right after the tag: </article>

I would like it if I had the the thread info there, without having to query it each time. From what I have read of the documentation, the only thing passed to a callback template modification is the match. I need to know the current post position and the total reply_count if the thread in the callback method..
 
If you dump $thread in the message template, you should find that reply_count is available.

Code:
{xen:helper dump, $thread}

upload_2014-10-21_20-57-18.webp
 
I was pointing out that the reply_count is available in the template already.

As Chris has already said, use a TM to perform any edits as required.
 
Sorry Brogan, still wrapping my head around the TMS.. I see what you are saying now. I just have to change the paradigm of my code to this new system. Thanks!
 
Back
Top Bottom