[eluser]Jagar[/eluser]
I don't know if there's anyway of doing this, but I couldn't find a way to access a helper function that I needed from the template.
Therefore I created a smarty plugin that you load any helper and function and use it.
I'm sure there are smarty users out there who may benefit from this.
First place this in the smarty plugin folder: plugins/function.access_helper.php
Code:
<?php
function smarty_function_access_helper($params, &$smarty){
if (!function_exists("get_instance")) {
return "Can't get CI instance";
}
if (!function_exists($params['function'])) {
$CI =& get_instance();
$CI->load->helper($params['name']);
}
$func = $params['function'];
return $func($params['value']);
}
?>
So within the template that is being parsed by smarty, you would use it as follow:
Code:
{access_helper name="helper_name" function="function_name_in_helper" value="value to be passed"}
The reason I made this is because I wanted to format the file size and needed to use the byte_format function inside number helper, so I used it as follow:
Code:
{access_helper name="number" function="byte_format" value="854565"}
and this will return the format byte
If there's a better way of doing this, please let me know.
Thanks!