4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: Lucifix on February 08, 2003, 02:19:44 PM
-
Is it possible to put comment and rate together. So you wont need to first rate photo and then post comment. I would like to do that all together.
-
the only way to do so, is put together rate form and coment form.
but in that case, u can not vote without posting the comments.
if u still whant this way, I think I can figure it out.
-
I not simple choice... but i will try it. At least people will say something :P
Oh... will it be possible to post a comment without rating photo?
-
yes, it possible post just comments.
if someone desided rate twice, it will just post a coment, and give him a message, that he already voted.
ok, here it is.
now visitors can post comment with/without voting and vote without comment :D
here what u need to do:
1.
Open /template/<yourtemplate>/coment_form.html
add this for example after <td>{bbcode}</td> </TR>
{if rate_form}
<TR>
<TD width="90" valign="top"> </TD>
<TD>
<TABLE border="0" cellspacing="0" cellpadding="3" class="row1">
<TR>
<TD>
<SELECT name="rating" class="select">
<OPTION value="">--</OPTION>
<OPTION value="5">5</OPTION>
<OPTION value="4">4</OPTION>
<OPTION value="3">3</OPTION>
<OPTION value="2">2</OPTION>
<OPTION value="1">1</OPTION>
</SELECT>
</TD>
<TD>
<INPUT type="submit" value="{rate}" class="button" name="submit" onClick="this.document.commentform.action.value='rateimage';"/>
</TD>
</TR>
</TABLE>
</TD>
</TR>
{endif rate_form}
2.
Open details.php file.
Find: $sql = "INSERT INTO ".COMMENTS_TABLE."
add just before it (above it ;) )://-----------------------------------------------------
//--- Save Rating -------------------------------------
//-----------------------------------------------------
if (intval($HTTP_POST_VARS['rating']) != "") {
$rating = intval($HTTP_POST_VARS['rating']);
$cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
$cookie_rated = isset($HTTP_COOKIE_VARS[$cookie_name.'rated']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'rated'])) : array();
if ($rating && $rating <= MAX_RATING && $id) {
if (!isset($session_info['rated_imgs'])) {
$session_info['rated_imgs'] = $site_sess->get_session_var("rated_imgs");
}
$split_list = array();
if (!empty($session_info['rated_imgs'])) {
$split_list = explode(" ", $session_info['rated_imgs']);
}
if (!in_array($id, $split_list) && !in_array($id, $cookie_rated)) {
$session_info['rated_imgs'] .= " ".$id;
$session_info['rated_imgs'] = trim($session_info['rated_imgs']);
$site_sess->set_session_var("rated_imgs", $session_info['rated_imgs']);
$cookie_rated[] = $id;
$cookie_expire = time() + 60 * 60 * 24 * 4;
setcookie($cookie_name.'rated', serialize($cookie_rated), $cookie_expire, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);
update_image_rating($id, $rating);
$msg_color = 1;
$msg = $lang['voting_success'];
}
else {
$msg = $lang['already_voted'];
}
}
else {
$msg = $lang['voting_error'];
}
}
//////////////////////////////////////////
u all done.
-
thanks alot V@no, for your support. I didn't try this code yet, couse my free server is still down :cry:
-
V@no... i dont think it works... look at my site: http://members.lycos.co.uk/mgalerija/4images/details.php?image_id=79
Now there are 2 rates. I think i should delete one
Or maybe I have inserted your code in wrong line? I think the problem is in coment_form.html file. Here is the code for it:
<table width="100%" border="0" cellspacing="0" cellpadding="1" align="center">
<tr>
<td valign="top" class="head1">
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr>
<td valign="top" class="head1">{lang_post_comment}</td>
</tr>
<tr>
<td valign="top" class="row1">
<form name="commentform" action="{self}" method="post" onsubmit="postbutton.disabled=true;">
<table cellpadding="4" cellspacing="0" border="0">
<tr>
<td width="90"><b>{lang_name}</b></td>
<td>
<input type="text" name="user_name" size="30" value="{user_name}" class="commentinput" />
</td>
</tr>
<tr>
<td width="90"><b>{lang_headline}</b></td>
<td>
<input type="text" name="comment_headline" size="30" value="{comment_headline}" class="commentinput" />
</td>
</tr>
<tr>
<td width="140" valign="top"><b>{lang_comment}</b></td>
<td>
<textarea name="comment_text" cols="35" rows="10" class="commenttextarea">{comment_text}</textarea>
</td>
</tr>
<tr>
<td width="90" valign="top"> </td>
<td>{bbcode}</td>
</tr>
<tr>
<td width="90" valign="top"> </td>
<td>
<input type="hidden" name="action" value="postcomment" />
<input type="hidden" name="id" value="{image_id}" />
<input type="submit" name="postbutton" value="{lang_post_comment}" class="button" />
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</td>
</TR>
{if rate_form}
<TR>
<TD width="90" valign="top"> </TD>
<TD>
<TABLE border="0" cellspacing="0" cellpadding="3" class="row1">
<TR>
<TD>
<SELECT name="rating" class="select">
<OPTION value="">--</OPTION>
<OPTION value="5">5</OPTION>
<OPTION value="4">4</OPTION>
<OPTION value="3">3</OPTION>
<OPTION value="2">2</OPTION>
<OPTION value="1">1</OPTION>
</SELECT>
</TD>
<TD>
<INPUT type="submit" value="{rate}" class="button" name="submit" onClick="this.document.commentform.action.value='rateimage';"/>
</TD>
</TR>
</TABLE>
</TD>
</TR>
{endif rate_form}
</tr>
</table>
-
Yes its working now. But it still shows 2 rates. And if you rate a photo you can do it for next time 2. Or maybe I have inserted wrong code in details.php file? :oops:
Here is come of the code:
}
if ($comment_text == "") {
$msg .= (($msg != "") ? "<br />" : "").$lang['comment_required'];
$error = 1;
}
if (!$error)
//-----------------------------------------------------
//--- Save Rating -------------------------------------
//-----------------------------------------------------
if (intval($HTTP_POST_VARS['rating']) != "") {
$rating = intval($HTTP_POST_VARS['rating']);
$cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
$cookie_rated = isset($HTTP_COOKIE_VARS[$cookie_name.'rated']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'rated'])) : array();
if ($rating && $rating <= MAX_RATING && $id) {
if (!isset($session_info['rated_imgs'])) {
$session_info['rated_imgs'] = $site_sess->get_session_var("rated_imgs");
}
$split_list = array();
if (!empty($session_info['rated_imgs'])) {
$split_list = explode(" ", $session_info['rated_imgs']);
}
if (!in_array($id, $split_list) && !in_array($id, $cookie_rated)) {
$session_info['rated_imgs'] .= " ".$id;
$session_info['rated_imgs'] = trim($session_info['rated_imgs']);
$site_sess->set_session_var("rated_imgs", $session_info['rated_imgs']);
$cookie_rated[] = $id;
$cookie_expire = time() + 60 * 60 * 24 * 4;
setcookie($cookie_name.'rated', serialize($cookie_rated), $cookie_expire, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);
update_image_rating($id, $rating);
$msg_color = 1;
$msg = $lang['voting_success'];
}
else {
$msg = $lang['already_voted'];
}
}
else {
$msg = $lang['voting_error'];
}
}
//////////////////////////////////////////
{
$sql = "INSERT INTO ".COMMENTS_TABLE."
(image_id, user_id, user_name, comment_headline, comment_text, comment_ip, comment_date)
VALUES
-
{
$sql = "INSERT INTO ".COMMENTS_TABLE."
what is that extra { ?
-
what is that extra { ?
I have inserted your code before {
$sql = "INSERT INTO ".COMMENTS_TABLE."
Wrong?
-
I would just like to tell you that it looks like its working now. When i try to rate again i get this message: you have already rated this image.
But still there are 2 rating system. How should i disable upper one?
-
sry, my bad, in my code that { is on same line with IF....
:oops:
to rid off old rate form, just delete {if rate_form}
<DIV align="center">
{rate_form}
</DIV>
<BR />
{endif rate_form}
from detail.html template. ( it might be little different in your template)
-
sry, my bad, in my code that { is on same line with IF....
come on v@no... master like you problem like this shouldnt happened :lol: just kidding man... you done it again, this looks just great!
Thanks alot!
Lucifix
-
Hi V@no,
thanks a lot for this nice mod! I just added it and it works.
Just a little bug I found: if you rate only, there is a message and it says that you have to add a comment. That's OK so far. Nevertheless an empty comment appears if you hit the same image in categories. Theres the name of the user but an empty comments-field.
How could I supress this in a way that nothing appears if you haven't postet a comment in addition?
Thanks in advance!
Biggi
-
I can not check it myself, but try this:
Find: if ($user_name == "") {
Replace with: if ($user_name == "" && intval($HTTP_POST_VARS['rating']) != "" && ($comment_text != "" || $comment_headline != "")) {
Find: if ($comment_headline == "") {
Replace with: if ($comment_headline == "" && intval($HTTP_POST_VARS['rating']) != "" && ($user_name != "" || $comment_headline != "")) {
Find: if ($comment_text == "") {
Replace with: if ($comment_text == "" && intval($HTTP_POST_VARS['rating']) != "" && ($user_name != "" || $comment_headline != "")) {
-
Thanks V@no, I had a try with this change, but it doesn't work.
But now I have a much more important problem and a question:
since I've put together rate form and comment form my users tell me, that they have problems with sending comment and rating together, if they use the Internet-Explorer Version 6 or Mozilla and some other Browsers. I'm using Internet-Explorer 5.5 and there's never any problem, so I can't see this bug in action and did not even regognize it :roll:
Do you have an idea, how to fix this? Otherwise I would have to change this nice Mod back to the earlier version, but I would'nt prefer it :cry:
Can you help me out?
Regards, Biggi
-
what kind of problem?
I dont see anything that could cause problems in none IE browsers...
-
I dont understand it, too :roll:
But they are not able to send comment AND rating together. They have to send the rating afterwards and sometime even this doesn't work.
:cry:
-
Hi V@no,
please: just forget it. Im sorry to have made you wonder :wink:
Together with my users we just found out, that they made mistakes in handling the rating. Now everything works well, because now it is clear to them how to do.
Im glad I have'nt changed the code back to the roots. Never change a running system... And never underrate the confusion of your users :D :D :D
Everything works well now!
Good night with kind regards,
Biggi
-
the only way to do so, is put together rate form and coment form.
but in that case, u can not vote without posting the comments.
if u still whant this way, I think I can figure it out.
That is just I need, I need put together the rate form an comment form so the users can't vote without comment.
I've tried to put together the two forms but I have not been able to do it.
This is the code that I have in comment_form template:
<table width="100%" border="0" cellspacing="0" cellpadding="1" align="center">
<tr>
<td valign="top" class="head1">
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr>
<td valign="top" class="head1">{lang_post_comment}</td>
</tr>
<tr>
<td valign="top" class="row1">
<form name="commentform" action="{self}" method="post" onsubmit="postbutton.disabled=true;">
<table cellpadding="4" cellspacing="0" border="0">
<tr>
<td width="90"><b>{lang_name}</b></td>
<td>
<input type="text" name="user_name" size="30" value="{user_name}" class="commentinput" />
</td>
</tr>
<tr>
<td width="90"><b>{lang_headline}</b></td>
<td>
<input type="text" name="comment_headline" size="30" value="{comment_headline}" class="commentinput" />
</td>
</tr>
<tr>
<td width="140" valign="top"><b>{lang_comment}</b></td>
<td>
<textarea name="comment_text" cols="35" rows="10" class="commenttextarea">{comment_text}</textarea>
</td>
</tr>
<tr>
<td width="90" valign="top"> </td>
<td>{bbcode}</td>
</TR>
<TR>
<TD width="90" valign="top"> </TD>
<TD>
<TABLE border="0" cellspacing="0" cellpadding="3" class="row1">
<TR>
<TD>
<select name="rating" class="select">
<option value="">--</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select>
</TD>
</tr>
<tr>
<td width="90" valign="top"> </td>
<td>
<input type="hidden" name="action" value="postcomment" />
<input type="hidden" name="id" value="{image_id}" />
<input type="submit" name="postbutton" value="{lang_post_comment}" class="button" />
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
Any idea?
-
Hat denn jemand schon eine Lösung für - Kommentar und Bewertung - gleichzeitig abgeben, gefunden.
Grüsse PetraK
-
V@no I have that same problem, can you fix the code?
I can not check it myself, but try this:
Find: if ($user_name == "") {
Replace with: if ($user_name == "" && intval($HTTP_POST_VARS['rating']) != "" && ($comment_text != "" || $comment_headline != "")) {
Find: if ($comment_headline == "") {
Replace with: if ($comment_headline == "" && intval($HTTP_POST_VARS['rating']) != "" && ($user_name != "" || $comment_headline != "")) {
Find: if ($comment_text == "") {
Replace with: if ($comment_text == "" && intval($HTTP_POST_VARS['rating']) != "" && ($user_name != "" || $comment_headline != "")) {
-
I am not able to see the VOTE that I gave near my comment...AM I false?
I think I have to see my rating that I gave near my comment ...right?