forum.coppermine-gallery.net
No Support => Modifications/Add-Ons/Hacks => Mods: Voting/Rating => Topic started by: SaWey on January 31, 2007, 10:00:28 am
-
I've been working on the voting of cpg,
I thought it could use some new voting pic.
Edit:
Before you read any further, this has still a giant bug in it.
In Firefox everything works fine, but IE won't let you vote for the moment.
This is caused by the referer in the code in "ratepic.php" at line 39.
If you comment this out, it will work in both IE and Firefox, but be carefull:
If the referer isn't checked, it is possible to vote from another website!
Solution to this ex-problem can be found at the bottom
To intall this, follow these steps:
First of all, copy the attached files in there corresponding folders:
rating.js -> scripts/rating
new.gif -> images
full.gif -> images
empty.gif -> images
Then in your "template.html" add the following above the </head> tag:
<script type="text/javascript" src="scripts/rating/rating.js"></script>
And as a last change, in your "theme.php" file add the following code before "?>"
//Rating change
$template_image_rating = <<<EOT
<table align="center" width="{WIDTH}" cellspacing="1" cellpadding="0" class="maintable">
<tr>
<td colspan="6" class="tableh2_compact"><b>{TITLE}</b> {VOTES}</td>
</tr>
<tr>
<td class="tableb_compact">{RATESCRIPT}</td>
</tr>
</table>
EOT;
function theme_html_rating_box()
{
global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR;
global $template_image_rating, $lang_rate_pic;
if (!(USER_CAN_RATE_PICTURES && $CURRENT_ALBUM_DATA['votes'] == 'YES')) return '';
$votes = $CURRENT_PIC_DATA['votes'] ? sprintf($lang_rate_pic['rating'], round($CURRENT_PIC_DATA['pic_rating'] / 2000, 1), $CURRENT_PIC_DATA['votes']) : $lang_rate_pic['no_votes'];
$pid = $CURRENT_PIC_DATA['pid'];
if (defined('THEME_HAS_RATING_GRAPHICS')) {
$location= $THEME_DIR;
} else {
$location= '';
}
$params = array('{TITLE}' => $lang_rate_pic['rate_this_pic'],
'{RATESCRIPT}' => '<script type="text/javascript" language="JavaScript">displayStars(' . round($CURRENT_PIC_DATA['pic_rating'] / 2000, 0) . ', ' . $pid . ', "");</script>',
'{VOTES}' => $votes,
'{WIDTH}' => $CONFIG['picture_table_width'],
'{LOCATION}' => $location, //theme dir or default images directory
);
return template_eval($template_image_rating, $params);
}
To escape the ex-problem in IE, just
Change the code in "ratepic.php" at line 39 to
// If referer is not displayimage.php we don't accept the vote
$referer = $_SERVER["HTTP_REFERER"];
if (!eregi("displayimage", $referer) & !($referer == "")){
header('Location: displayimage.php?pos=' . (- $pic));
exit;
}
Now it works.
Have fun.
-
Hi
Thanks for this. It's really useful.
I've changed it for my site to allow me to use a 1 - 10 scale which was very easy to do.
Thanks again for making this available.
Alan
http://www.digital-imaging-associates.com (http://www.digital-imaging-associates.com)
-
I'm glad it's usefull!
Nice site BTW
-
I don't know if any moderator will see this, but if you do,
can't you place this topic in the mods-section (visuals or something)
Thanks
-
It is (coppermine-gallery.net > No Support > Modifications/Add-Ons/Hacks > Mods: Voting/Rating). Nibbler moved it here. Shouldn't have gone into the bugs board in the first place imo.
-
hey there..
ah what does this actually do?
-
This replaces the standard voting pictures with only one picture and adds some rollover effects.
You should try it,
It's realy nice.
-
nice 1...
now we just need some kind of ajaxified voting and we're set! (so the page doesn't reload when you submit your vote)
-
Hiya SaWey... another great mod... I had it working fine on my site and then with my endless theme tweaking I managed to screw it up... now it returns the dreaded "selected album/file does not exist" message whenever a vote is cast. I noticed that it changes from mysite/displayimage.php?album=#&pos=-# to mysite/displayimage.php?pos=-# (no album is identified). Is the fix in the ratepic.php ?
Thanks for any help with this.
-
And as a last change, in your "theme.php" file add the following code before "?>"
hi dears,
i did not change , rating , well, i have not "theme.php" like you , could you fix problem , many thx,
note: my "theme.php" is below
define('THEME_IS_XHTML10_TRANSITIONAL',1); // Remove this if you edit this template until
// you have validated it. See docs/theme.htm.
// HTML template for template sys_menu spacer
$template_sys_menu_spacer ='<img src="themes/water_drop/images/orange_carret.gif" width="8" height="8" border="0" alt="" />';
?>
-
If a function or var definition doesn't exist in your cutom theme, copy the corresponding section from the sample theme. In your case, paste
//Rating change
$template_image_rating = <<<EOT
<table align="center" width="{WIDTH}" cellspacing="1" cellpadding="0" class="maintable">
<tr>
<td colspan="6" class="tableh2_compact"><b>{TITLE}</b> {VOTES}</td>
</tr>
<tr>
<td class="tableb_compact">{RATESCRIPT}</td>
</tr>
</table>
EOT;
function theme_html_rating_box()
{
global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR;
global $template_image_rating, $lang_rate_pic;
if (!(USER_CAN_RATE_PICTURES && $CURRENT_ALBUM_DATA['votes'] == 'YES')) return '';
$votes = $CURRENT_PIC_DATA['votes'] ? sprintf($lang_rate_pic['rating'], round($CURRENT_PIC_DATA['pic_rating'] / 2000, 1), $CURRENT_PIC_DATA['votes']) : $lang_rate_pic['no_votes'];
$pid = $CURRENT_PIC_DATA['pid'];
if (defined('THEME_HAS_RATING_GRAPHICS')) {
$location= $THEME_DIR;
} else {
$location= '';
}
$params = array('{TITLE}' => $lang_rate_pic['rate_this_pic'],
'{RATESCRIPT}' => '<script type="text/javascript" language="JavaScript">displayStars(' . round($CURRENT_PIC_DATA['pic_rating'] / 2000, 0) . ', ' . $pid . ', "");</script>',
'{VOTES}' => $votes,
'{WIDTH}' => $CONFIG['picture_table_width'],
'{LOCATION}' => $location, //theme dir or default images directory
);
return template_eval($template_image_rating, $params);
}
into a new line before?>
-
Hiya SaWey... another great mod... I had it working fine on my site and then with my endless theme tweaking I managed to screw it up... now it returns the dreaded "selected album/file does not exist" message whenever a vote is cast. I noticed that it changes from mysite/displayimage.php?album=#&pos=-# to mysite/displayimage.php?pos=-# (no album is identified). Is the fix in the ratepic.php ?
Thanks for any help with this.
You should check some things:
Open a voting page and look into the source, find "<SCRIPT language=JavaScript type=text/javascript>displayStars",
It should end with something like this: "displayStars(0, 217, "");</SCRIPT>" Where the 217 is the number of the picture.
If that isn't in there, no pic will be defined and the problem lies within your theme.php file.
If so, please post your theme.php source in this thread.
-
Yea.. must be the theme... here it is, long one... with your cool lightbox mod as well.
i am having problems posting it because of the length, would you mind looking at a zip?
-
not at all, please post it
-
Cool thanks
-
Is this the correct theme.php file?
Cause I can't seem to find anything related to the voting mod?
have you added the code as suggested at the top of this thread?
-
ah. yea forgot to mention that. i took out the mod when i was trying to troubleshoot. It was just a unmodified copy of what you have in this thread.
anyways... I guess the problem is totally unrelated to your mod and is rather some other problem in my voting system. I should probably make a diff thread for this i guess.. sorry bout that.
-
Nice mod. It works great. I have a request if you are willing. Could you guide me in the process of how to change the rating system to 10 stars instead of 5?
all the best,
Joe
-
Could you guide me in the process of how to change the rating system to 10 stars instead of 5?
Not related to this mod. Ask that question in a new thread on the support board after having searched for instructions how to accomplish what you're up to - I'm pretty sure that this has already been explained. Please do not clutter mod announcement threads with unrelated stuff in the future.
I created a demo theme based on the classic theme that comes with coppermine and bundled it with this mod. The bundle contains everything you need but the changes in ratepic.php.
To make this an actual theme, I changed the location of the extra files and modified the js file a bit (should be self-explanatory).
To see what the mod does, take a look at http://coppermine-gallery.net/demo/cpg14x/index.php?theme=classic_rating and try voting for any file.
Download my modified version of the classic theme (named "classic_rating") that contains all needed files originally created by SaWey here: http://downloads.sourceforge.net/coppermine/cpg1.4.x_theme_classic_rating.zip
-
Thanks for your reply. i tried the link you provided and I was not able to rate an image. There was no option and no stars visible. I was logged in.
all the best,
Joe
-
Make sure you are not using internet explorer as the title mentioned
-
Try http://coppermine-gallery.net/demo/cpg14x/thumbnails.php?album=20&theme=classic_rating and browse the files there.
-
Hello
this is a very nice plugin..but I have a question, when I vote, and than vote encore..than I become a error, that I have voted! Can I remove the error, but the vote dont add!?
sry for my english
-
am i missing a folder because 1.4.18 doesn't have a scripts folder
-
You can just create that folder if it doesn't exist
-
beautiful voting solution! Thanks so much for putting this together. =]
-
Scipt is great....but i don't understand how i could change the numer of stars
for voting.... ???
Rich
-
Very great Mod.
I have a question did anyone have an idea how I can include an noscript tag for the standart rating?
So if you have activate javascript you see the nicer voting. And if javascript is deactivated the orginal voting system is shown?
If somebody have an idea it would be very nice if he can help me.
-
Is it possible to put Your system under image? (not under filmstrip?)
werol.
I've been working on the voting of cpg,
I thought it could use some new voting pic.
Edit:
Before you read any further, this has still a giant bug in it.
In Firefox everything works fine, but IE won't let you vote for the moment.
This is caused by the referer in the code in "ratepic.php" at line 39.
If you comment this out, it will work in both IE and Firefox, but be carefull:
If the referer isn't checked, it is possible to vote from another website!
Solution to this ex-problem can be found at the bottom
To intall this, follow these steps:
First of all, copy the attached files in there corresponding folders:
rating.js -> scripts/rating
new.gif -> images
full.gif -> images
empty.gif -> images
Then in your "template.html" add the following above the </head> tag:
<script type="text/javascript" src="scripts/rating/rating.js"></script>
And as a last change, in your "theme.php" file add the following code before "?>"
//Rating change
$template_image_rating = <<<EOT
<table align="center" width="{WIDTH}" cellspacing="1" cellpadding="0" class="maintable">
<tr>
<td colspan="6" class="tableh2_compact"><b>{TITLE}</b> {VOTES}</td>
</tr>
<tr>
<td class="tableb_compact">{RATESCRIPT}</td>
</tr>
</table>
EOT;
function theme_html_rating_box()
{
global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR;
global $template_image_rating, $lang_rate_pic;
if (!(USER_CAN_RATE_PICTURES && $CURRENT_ALBUM_DATA['votes'] == 'YES')) return '';
$votes = $CURRENT_PIC_DATA['votes'] ? sprintf($lang_rate_pic['rating'], round($CURRENT_PIC_DATA['pic_rating'] / 2000, 1), $CURRENT_PIC_DATA['votes']) : $lang_rate_pic['no_votes'];
$pid = $CURRENT_PIC_DATA['pid'];
if (defined('THEME_HAS_RATING_GRAPHICS')) {
$location= $THEME_DIR;
} else {
$location= '';
}
$params = array('{TITLE}' => $lang_rate_pic['rate_this_pic'],
'{RATESCRIPT}' => '<script type="text/javascript" language="JavaScript">displayStars(' . round($CURRENT_PIC_DATA['pic_rating'] / 2000, 0) . ', ' . $pid . ', "");</script>',
'{VOTES}' => $votes,
'{WIDTH}' => $CONFIG['picture_table_width'],
'{LOCATION}' => $location, //theme dir or default images directory
);
return template_eval($template_image_rating, $params);
}
To escape the ex-problem in IE, just
Change the code in "ratepic.php" at line 39 to
// If referer is not displayimage.php we don't accept the vote
$referer = $_SERVER["HTTP_REFERER"];
if (!eregi("displayimage", $referer) & !($referer == "")){
header('Location: displayimage.php?pos=' . (- $pic));
exit;
}
Now it works.
Have fun.
-
You will not be supported, as the gallery from your profile URL http://art-club.pl/ is deliberately hiding the "Powered by Coppermine" footer, which is a license breach. Restore the footer permanently. Respect board rules in the future after having restored the footer. If you don't, then go away and stay away.
-
I've been working on the voting of cpg,
I thought it could use some new voting pic.
Edit:
Before you read any further, this has still a giant bug in it.
In Firefox everything works fine, but IE won't let you vote for the moment.
This is caused by the referer in the code in "ratepic.php" at line 39.
If you comment this out, it will work in both IE and Firefox, but be carefull:
If the referer isn't checked, it is possible to vote from another website!
Solution to this ex-problem can be found at the bottom
To intall this, follow these steps:
First of all, copy the attached files in there corresponding folders:
rating.js -> scripts/rating
new.gif -> images
full.gif -> images
empty.gif -> images
Then in your "template.html" add the following above the </head> tag:
<script type="text/javascript" src="scripts/rating/rating.js"></script>
And as a last change, in your "theme.php" file add the following code before "?>"
//Rating change
$template_image_rating = <<<EOT
<table align="center" width="{WIDTH}" cellspacing="1" cellpadding="0" class="maintable">
<tr>
<td colspan="6" class="tableh2_compact"><b>{TITLE}</b> {VOTES}</td>
</tr>
<tr>
<td class="tableb_compact">{RATESCRIPT}</td>
</tr>
</table>
EOT;
function theme_html_rating_box()
{
global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR;
global $template_image_rating, $lang_rate_pic;
if (!(USER_CAN_RATE_PICTURES && $CURRENT_ALBUM_DATA['votes'] == 'YES')) return '';
$votes = $CURRENT_PIC_DATA['votes'] ? sprintf($lang_rate_pic['rating'], round($CURRENT_PIC_DATA['pic_rating'] / 2000, 1), $CURRENT_PIC_DATA['votes']) : $lang_rate_pic['no_votes'];
$pid = $CURRENT_PIC_DATA['pid'];
if (defined('THEME_HAS_RATING_GRAPHICS')) {
$location= $THEME_DIR;
} else {
$location= '';
}
$params = array('{TITLE}' => $lang_rate_pic['rate_this_pic'],
'{RATESCRIPT}' => '<script type="text/javascript" language="JavaScript">displayStars(' . round($CURRENT_PIC_DATA['pic_rating'] / 2000, 0) . ', ' . $pid . ', "");</script>',
'{VOTES}' => $votes,
'{WIDTH}' => $CONFIG['picture_table_width'],
'{LOCATION}' => $location, //theme dir or default images directory
);
return template_eval($template_image_rating, $params);
}
To escape the ex-problem in IE, just
Change the code in "ratepic.php" at line 39 to
// If referer is not displayimage.php we don't accept the vote
$referer = $_SERVER["HTTP_REFERER"];
if (!eregi("displayimage", $referer) & !($referer == "")){
header('Location: displayimage.php?pos=' . (- $pic));
exit;
}
Now it works.
Have fun.
hello,
can this code jump after vote to the next picture to vote?
this is something what i´m loking for.