XF 2.2 Obtaining Thread ID in Custom Class?

notherek

New member
I'm trying to figure out how I can obtain the thread ID from a custom class. This is something that is likely fairly easy, but I'm still very new to Xenforo and am learning. I searched around Google and the forums here and haven't been able to find anything useful. I see a lot of how to reference it in templates, but I need the ID in the class.

I have this in my templates
<xf:callback class="\CTM\Misc\MyTags" method="getTags"></xf:callback>

And here's my class
Code:
<?php
namespace CTM\Misc;

class MyTags {
    public static function getTags() {
        return "<meta name='test' value='test'>";
    }
}
?>

It works fine as-is, but I want to return some properties based on the thread ID. Other than trying to parse it from the request string, are there any other variable references I can use?

Edit: I also tried adding a parameter to the function and callback, but it's not helping either.
<xf:callback class="\CTM\Misc\MyTags" method="getTags" params="['{$thread.thread_id}']" ></xf:callback>

Edit2: I should add that I'm in the metadata_macros template
 
Last edited:
Nevermind, I got it with
public static function getImageTags($contents, $params) {

and
params="[{$__globals.contentKey}]"

:D
 
getImageTags isn't a method of XenForo built-in class right? does it get called only by xf:callback? if that's the case, you have to pass an argument.

I'm pretty sure there are other ways to do this without touching $__globals
 
I would be VERY curious to learn, if you have an example. It works using $__globals but if that's not the best practice...
I'm not sure about what exactly you are trying to do, but if it has anything to do with Thread ID, didn't you try to extend the thread controller class using XFCP?
 
Back
Top Bottom