I'm using datalife engine to make a blog, and I'm trying to tweak the default rating module.
In DLE, the default rating, displays 5 stars and the number of votes. I want to add an actual score from 0 to 10 based on that info.
In the SQL db, the info is stored in the table "dle_post_extras", and it has two columns, "rating" and "vote_num". So I need the final result to be = "rating" /(dividing) "vote_num" in that specific "id".
For what i could figure out, [rating] and {rating} that are used on the tpl files to display the rating info, they are defined in show.full.php like this
if( $row['allow_rate'] ) {
$tpl->set( '{rating}', ShowRating( $row['id'], $row['rating'], $row['vote_num'], $user_group[$member_id['user_group']]['allow_rating'] ) );
$tpl->set( '{vote-num}', "<span id=\"vote-num-id-".$row['id']."\">".$row['vote_num']."</span>" );
$tpl->set( '[rating]', "" );
$tpl->set( '[/rating]', "" );
} else {
$tpl->set( '{rating}', "" );
$tpl->set( '{vote-num}', "" );
$tpl->set_block( "'\\[rating\\](.*?)\\[/rating\\]'si", "" );
}
I don't want to change this part, i need to be able to still use it. Can you help me how to query the db for that two values and dividing them one by each other, and how to display them? Oh, the final "score" can only have one decimal number. The output can only be for ex: 7.1, 8.6, 4.2 etc etc
EDIT:
Ok, so i want something like this
$tpl->set( '{rating_num}',$row['rating'] dividing by $row['vote_num']);
and this value rounded to 1 decimal house