Jump to content


New Member
  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About nisompic

  • Rank
    Junior Member
  1. Hello, I am trying to define a custom modifier for Smarty templates in my provisioning module. I have tried multiple methods but they all seem to fail. My first try was using a Hook on ClientAreaPage where my function would register a Smarty modifier: <?php function hr_size($bytes) { $size = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); $factor = floor((strlen($bytes) - 1) / 3); $dec = 2; return sprintf("%.{$dec}f", $bytes / pow(1024, $factor)) . @$size[$factor]; } add_hook('ClientAreaPage', 1, function ($vars) { global $smarty; $smarty->registerPlugin('modifier', 'humanReadable', 'hr_size'); }); Unfortunately, when using the modifier in the template file returned by module_ClientArea(), the template is not shown and I get the following error in the Activity Log: Syntax error in template "file:..." on line 5 "{$object.Size|humanReadable} |" unknown modifier 'humanReadable' I have then tried this very same way by declaring global $smarty; in my module_ClientArea() function and registering the modifier there, but it did not work either. I'm at a loss on what to try next, has anyone ever done something similar and made it work? I'm using WHMCS 7.10 .
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated