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

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

#1
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?
 

Indigo

Active member
#2
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:
PHP:
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).