XF 2.1 Widget PHP callback (or something)

TLDR

Active member
Hi!

I am preparing the update of a forum currently running XF 1.5. It has a custom sidebar widget which was implemented by a template modification and a PHP callback.

So the current set-up is:

Template-Mod:
Code:
<xen:callback class="mycompany_partner" method="getPartnerLinks"></xen:callback>

library/mycompany/partner.php:
PHP:
<?php

class mycompany_partner {
    
    public static function getPartnerLinks() {
        
        return '<a href="https://google.com">Google</a>';
        
    }
    
}

Now I saw, XF 2.1 has a widget administration builtin where I can manage custom widgets. That's awesome. However, I'm a little desperate on how I would port this code over to XF 2.1.

So what's better, a template callback or a PHP Callback widget? And how would I do this? Where do I put the files? How is XF looking for the files?

Thank you!
 

TLDR

Active member
Alright, I just found the developer documentation, especially this:


Turns out, my namespace is "mycompany", the class name is just "partner" and the callback looks like this:
Code:
<xf:callback class="mycompany\\partner" method="getPartnerLinks"></xf:callback>

Put that file into src/addons/mycompany/partner.php and boom, done.
 
Top