Author Topic: comment and rate  (Read 25547 times)

0 Members and 1 Guest are viewing this topic.

Offline Lucifix

  • Hero Member
  • *****
  • Posts: 710
    • View Profile
    • http://www.slo-foto.net
comment and rate
« 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.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
comment and rate
« Reply #1 on: February 08, 2003, 03:58:27 PM »
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.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Lucifix

  • Hero Member
  • *****
  • Posts: 710
    • View Profile
    • http://www.slo-foto.net
comment and rate
« Reply #2 on: February 08, 2003, 04:02:13 PM »
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?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
comment and rate
« Reply #3 on: February 08, 2003, 04:26:42 PM »
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>
Code: [Select]
                               </TR>
{if rate_form}
                <TR>
                  <TD width="90" valign="top">&nbsp;</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:
Code: [Select]
     $sql = "INSERT INTO ".COMMENTS_TABLE."

add just before it (above it ;) ):
Code: [Select]
//-----------------------------------------------------
//--- 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.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Lucifix

  • Hero Member
  • *****
  • Posts: 710
    • View Profile
    • http://www.slo-foto.net
comment and rate
« Reply #4 on: February 08, 2003, 10:19:36 PM »
thanks alot V@no, for your support. I didn't try this code yet, couse my free server is still down  :cry:

Offline Lucifix

  • Hero Member
  • *****
  • Posts: 710
    • View Profile
    • http://www.slo-foto.net
comment and rate
« Reply #5 on: February 09, 2003, 08:15:34 PM »
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:
Quote
<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">&nbsp;</td>
                  <td>{bbcode}</td>
                </tr>
                <tr>
                  <td width="90" valign="top">&nbsp;</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">&nbsp;</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>

Offline Lucifix

  • Hero Member
  • *****
  • Posts: 710
    • View Profile
    • http://www.slo-foto.net
comment and rate
« Reply #6 on: February 09, 2003, 08:43:05 PM »
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:
Quote
}
    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

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
comment and rate
« Reply #7 on: February 09, 2003, 08:59:24 PM »
Quote

{
$sql = "INSERT INTO ".COMMENTS_TABLE."

what is that extra { ?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Lucifix

  • Hero Member
  • *****
  • Posts: 710
    • View Profile
    • http://www.slo-foto.net
comment and rate
« Reply #8 on: February 09, 2003, 09:08:59 PM »
Quote
what is that extra { ?


I have inserted your code before
Quote
{
$sql = "INSERT INTO ".COMMENTS_TABLE."


Wrong?

Offline Lucifix

  • Hero Member
  • *****
  • Posts: 710
    • View Profile
    • http://www.slo-foto.net
comment and rate
« Reply #9 on: February 09, 2003, 09:14:14 PM »
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?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
comment and rate
« Reply #10 on: February 09, 2003, 09:36:05 PM »
sry, my bad, in my code that { is on same line with IF....
 :oops:

to rid off old rate form, just delete
Code: [Select]
{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)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Lucifix

  • Hero Member
  • *****
  • Posts: 710
    • View Profile
    • http://www.slo-foto.net
comment and rate
« Reply #11 on: February 09, 2003, 09:44:25 PM »
Quote
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

Offline Biggi

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • http://www.bibodia.de/
comment and rate
« Reply #12 on: March 22, 2003, 10:42:12 AM »
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

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
comment and rate
« Reply #13 on: March 22, 2003, 01:37:46 PM »
I can not check it myself, but try this:
Find:
Code: [Select]
   if ($user_name == "")  {
Replace with:
Code: [Select]
   if ($user_name == "" && intval($HTTP_POST_VARS['rating']) != "" && ($comment_text != "" || $comment_headline != ""))  {

Find:
Code: [Select]
   if ($comment_headline == "")  {
Replace with:
Code: [Select]
   if ($comment_headline == "" && intval($HTTP_POST_VARS['rating']) != "" && ($user_name != "" || $comment_headline != ""))  {

Find:
Code: [Select]
   if ($comment_text == "")  {
Replace with:
Code: [Select]
   if ($comment_text == "" && intval($HTTP_POST_VARS['rating']) != "" && ($user_name != "" || $comment_headline != ""))  {
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Biggi

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • http://www.bibodia.de/
comment and rate
« Reply #14 on: April 30, 2003, 05:44:51 PM »
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