how do I use xen:helper getFileExtension in my template?


New member
Hi Guys,

I'm trying to get a file extension from a file using the getFileExtension helper.
I tried {xen:helper getFileExtension, $file.filename}
The $file.filename variable is set but it ain't working.

Any ideas?


Active member
getFileExtension is not listed as a helper callback in XenForo/Template/Helper/Core.php (what {xen:helper} uses).

I'm not 100% on this, but adding the following PHP code somewhere before rendering may work:
XenForo_Template_Helper_Core::$helperCallbacks['getfileextension'] =
    array('XenForo_Helper_File', 'getFileExtension');
Make sure the getfileextension stays in all lower-case. This should enable the getFileExtension helper for templates (and technically you could do this for any other functions you need in templates).