Due to some MOD restrictions, you will be able to show only one result using stars images! (See attachments for DEMO!!!)
However, you able to show extremely results in ratung values (not in images)!
Let`s go!
0. STEP. Make a backup all files will be changed!!!
1. Step
Correct 4images_voted table. Set new options on "vote" Type: decimal Length/value 4,2 As defined 0.00
2. Step
Add to the 4images_voted table new field "vote_time" int(11) No 0
3. Step
Open /includes/page_header.php and delete:
if ($user_info['user_level'] != GUEST) {
$sql = "SELECT user_id, image_id, vote
FROM ".VOTED_TABLE."
WHERE image_id = ".$id." AND user_id = ".$user_info['user_id'];
$rated = $site_db->query_firstrow($sql);
$rating = ($rated['vote']) ? $rated['vote'] : $rating;
}else{
$rated = FALSE;
}
3.1 Step
At the very end Locate:
?>
Add:
//-----------------------------------------------------
//--- LATEST VOTES ------------------------------------
//-----------------------------------------------------
$lastvoted = "";
$sql = "SELECT v.user_id, v.image_id, v.vote, v.vote_time, u.user_id, u.user_name, i.image_id, i.image_name
FROM ".VOTED_TABLE." v, ".USERS_TABLE." u, ".IMAGES_TABLE." i
WHERE v.user_id = u.user_id AND v.image_id = i.image_id
ORDER BY v.vote_time DESC
LIMIT 1";
$result = $site_db->query($sql);
while ($row = $site_db->fetch_array($result)) {
$lastv = '<div id="star"><br style="clear: both;" /><ul id="star0" class="star"><li id="starCur0" class="curr" title="'.$row['vote'].'" style="width: 0px;"></li></ul></div>';
$lastvoted .= "<tr>";
$lastvoted .= "<td align=\"left\" width=\"4\"></td>";
$lastvoted .= "<td align=\"left\">";
$lastvoted .= '<a href ="'.ROOT_PATH.'search.php?search_user='.$row['user_name'].'"><b>'.$row['user_name'].'</b></a>';
$lastvoted .= "</td>";
$lastvoted .= "<td width=\"50\" align=\"right\">";
$lastvoted .= ''.$lastv.''.$row['image_name'].'';
$lastvoted .= "</td>";
$lastvoted .= "</tr>";
}
$site_template->register_vars(array(
"lastvoted" => $lastvoted,
));
unset($lastvoted);
//-----------------------------------------------------
4. Step
Open /ajaxrating.php and find:
if ($action == "rateimage" && $id) {
Add below:
if ($user_info['user_level'] != GUEST) {
$sql = "SELECT user_id, image_id, vote
FROM ".VOTED_TABLE."
WHERE image_id = ".$id." AND user_id = ".$user_info['user_id'];
$rated = $site_db->query_firstrow($sql);
$rating = ($rated['vote']) ? $rated['vote'] : $rating;
}else{
$rated = FALSE;
}
4.1 Step
Find:
if (!in_array($id, $split_list) && !in_array($id, $cookie_rated)) {
Replace:
if (!in_array($id, $split_list) && !in_array($id, $cookie_rated) && !$rated) {
5 Step
Open /includes/functions.php:
Find:
function update_image_rating($image_id, $rating) {
global $site_db, $user_info;
Add below:
$current_time = time();
5.1 Step
Find:
$sql = "INSERT INTO ".VOTED_TABLE."
(user_id, image_id, vote)
VALUES
(".$user_info['user_id'].", ".$image_id.", ".$rating.")";
$site_db->query($sql);
Replace:
$sql = "INSERT INTO ".VOTED_TABLE."
(user_id, image_id, vote, vote_time)
VALUES
(".$user_info['user_id'].", ".$image_id.", ".$rating.", ".$current_time.")";
$site_db->query($sql);
6. Step:
Open templates/details.html
Find and delete:
<!-- ----------------------------------------------- -->
<!-- [MOD] Ajax Star Rating -------------- by Bash-T -->
<!-- START ----------------------------------------- -->
<script type="text/javascript">
YAHOO.namespace('rating');
YAHOO.rating.star={
display_percentage : false, //set to true if a percentaged value shall be shown beneath the stars.
display_lables: true, //set to true if a ranking label shall be displayed beneath the stars at mouseover.
//do not modify the properties below!
num : 0,
successfully_voted : false,
labels : [ '{ajax_rating_labels_0}' , '{ajax_rating_labels_1}', '{ajax_rating_labels_2}', '{ajax_rating_labels_3}', '{ajax_rating_labels_4}', '{ajax_rating_labels_5}'],
msgs : [ '{ajax_rating_messages_0}' , '{ajax_rating_messages_1}', '{ajax_rating_messages_2}']
};
</script>
<script type="text/javascript" src="scripts/ajaxrating.js"></script>
<!-- ----------------------------------------------- -->
<!-- [MOD] Ajax Star Rating -------------- by Bash-T -->
<!-- END ----------------------------------------- -->
6.1 Step:
Open templates/header.html
Find:
<!-- ----------------------------------------------- -->
<!-- [MOD] Ajax Star Rating -------------- by Bash-T -->
<!-- START ----------------------------------------- -->
<script type="text/javascript" src="scripts/yui/2.7.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="scripts/yui/2.7.0/build/json/json-min.js"></script>
<script type="text/javascript" src="scripts/yui/2.7.0/build/connection/connection-min.js"></script>
<!-- ----------------------------------------------- -->
<!-- [MOD] Ajax Star Rating -------------- by Bash-T -->
And replace:
<!-- ----------------------------------------------- -->
<!-- [MOD] Ajax Star Rating -------------- by Bash-T -->
<!-- START ----------------------------------------- -->
<script type="text/javascript" src="scripts/yui/2.7.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="scripts/yui/2.7.0/build/json/json-min.js"></script>
<script type="text/javascript" src="scripts/yui/2.7.0/build/connection/connection-min.js"></script>
<script type="text/javascript">
YAHOO.namespace('rating');
YAHOO.rating.star={
display_percentage : false, //set to true if a percentaged value shall be shown beneath the stars.
display_lables: true, //set to true if a ranking label shall be displayed beneath the stars at mouseover.
//do not modify the properties below!
num : 0,
successfully_voted : false,
labels : [ '{ajax_rating_labels_0}' , '{ajax_rating_labels_1}', '{ajax_rating_labels_2}', '{ajax_rating_labels_3}', '{ajax_rating_labels_4}', '{ajax_rating_labels_5}'],
msgs : [ '{ajax_rating_messages_0}' , '{ajax_rating_messages_1}', '{ajax_rating_messages_2}']
};
</script>
<script type="text/javascript" src="scripts/ajaxrating.js"></script>
<!-- ----------------------------------------------- -->
<!-- [MOD] Ajax Star Rating -------------- by Bash-T -->
<!-- END ----------------------------------------- -->
7. Step
Open templates/home.html
And locate this, where you want:
<TABLE border="0" cellpadding="5" cellspacing="0" width="400" class="tablehead">
<tr>
<TD class="tdhead">Last vote</TD>
</tr>
<TR>
<TD>Recent voted photo</TD>
</TR>
{lastvoted}
</TABLE>
In case you want to show rating values:
In step: 3.1 find:
//-----------------------------------------------------
//--- LATEST VOTES ------------------------------------
//-----------------------------------------------------
$lastvoted = "";
$sql = "SELECT v.user_id, v.image_id, v.vote, v.vote_time, u.user_id, u.user_name, i.image_id, i.image_name
FROM ".VOTED_TABLE." v, ".USERS_TABLE." u, ".IMAGES_TABLE." i
WHERE v.user_id = u.user_id AND v.image_id = i.image_id
ORDER BY v.vote_time DESC
LIMIT 1";
$result = $site_db->query($sql);
while ($row = $site_db->fetch_array($result)) {
$lastv = '<div id="star"><br style="clear: both;" /><ul id="star0" class="star"><li id="starCur0" class="curr" title="'.$row['vote'].'" style="width: 0px;"></li></ul></div>';
$lastvoted .= "<tr>";
$lastvoted .= "<td align=\"left\" width=\"4\"></td>";
$lastvoted .= "<td align=\"left\">";
$lastvoted .= '<a href ="'.ROOT_PATH.'search.php?search_user='.$row['user_name'].'"><b>'.$row['user_name'].'</b></a>';
$lastvoted .= "</td>";
$lastvoted .= "<td width=\"50\" align=\"right\">";
$lastvoted .= ''.$lastv.''.$row['image_name'].'';
$lastvoted .= "</td>";
$lastvoted .= "</tr>";
}
$site_template->register_vars(array(
"lastvoted" => $lastvoted,
));
unset($lastvoted);
//-----------------------------------------------------
Replace:
//-----------------------------------------------------
//--- LATEST VOTES ------------------------------------
//-----------------------------------------------------
$lastvoted = "";
$sql = "SELECT v.user_id, v.image_id, v.vote, v.vote_time, u.user_id, u.user_name, i.image_id, i.image_name
FROM ".VOTED_TABLE." v, ".USERS_TABLE." u, ".IMAGES_TABLE." i
WHERE v.user_id = u.user_id AND v.image_id = i.image_id
ORDER BY v.vote_time DESC
LIMIT 3";
$result = $site_db->query($sql);
while ($row = $site_db->fetch_array($result)) {
$lastv = ''.$row['vote'].'';
$lastvoted .= "<tr>";
$lastvoted .= "<td align=\"left\" width=\"4\"></td>";
$lastvoted .= "<td align=\"left\">";
$lastvoted .= '<a href ="'.ROOT_PATH.'search.php?search_user='.$row['user_name'].'"><b>'.$row['user_name'].'</b></a>';
$lastvoted .= "</td>";
$lastvoted .= "<td width=\"50\" align=\"right\">";
$lastvoted .= ''.$lastv.'';
$lastvoted .= "</td>";
$lastvoted .= "<td width=\"50\" align=\"right\">";
$lastvoted .= ''.$row['image_name'].'';
$lastvoted .= "</td>";
$lastvoted .= "</tr>";
}
$site_template->register_vars(array(
"lastvoted" => $lastvoted,
));
unset($lastvoted);
//-----------------------------------------------------
Additional info:
LIMIT 3 you may change as you need...