is there any way to replace this:
<div>{math equation="x - y" x={$n.total_rating} y={$n.total_ratings}}</div>
Where results is for example 1300 to receive this 1.3k, and so on...
is there any way to replace this:
<div>{math equation="x - y" x={$n.total_rating} y={$n.total_ratings}}</div>
Where results is for example 1300 to receive this 1.3k, and so on...
Try in libs\plugins\modifier.num_format.php
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsModifier
*/
function smarty_modifier_num_format($string) {
if($string>1000) {
$x = round($string);
$x_number_format = number_format($x);
$x_array = explode(',', $x_number_format);
$x_parts = array('k', 'm', 'b', 't');
$x_count_parts = count($x_array) - 1;
$x_display = $x;
$x_display = $x_array[0] . ((int) $x_array[1][0] !== 0 ? '.' . $x_array[1][0] : '');
$x_display .= $x_parts[$x_count_parts - 1];
return $x_display;
}
return $string;
}
and in theme file
{assign var="mynubers" value="{math equation="x - y" x={$n.total_rating} y={$n.total_ratings}}"}
{if $mynubers > '1000'}{$mynubers|num_format}{else}{$mynubers}{/if}