Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [MOD] Highlight comments (sNews 1.4)  (Read 11165 times)

Luka

  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 36
  • Posts: 1746
    • http://www.snewscms.com
[MOD] Highlight comments (sNews 1.4)
« on: January 25, 2006, 10:54:02 PM »

Some websites have every other comment highlighted. The first one is white, the second is grey and then white, gray...
Maybe we could do the same as an option.

Back in the old days I calculated even and odd numbers by using mod function. You divide it by 2 as many times as you can and then see if you have 1 or 0 left. You had to do it all manually.

I'll have to see what function is used these days, these kids now have all the fancy toys  ;D :D
Logged

bryn

  • sNews Dude
  • Hero Member
  • *****
  • Karma: 2
  • Posts: 939
    • http://www.cssugly.com
[MOD] Highlight comments (sNews 1.4)
« Reply #1 on: January 25, 2006, 11:04:09 PM »

also another useful function i have seen Luka is for the Admins comments to be featured in some way..either by highlighting them..insetting them..displaying an Admin logo..etc etc etc..mostly using an option involving css..but how do you grab Admins comments from the db to affect them when written?

get my drift..gettin sleepy here and probably not making sense ;D
Logged
Over 1,000 posts of joy, sNews is not only brilliant, but fun too! thanks guys :D

Luka

  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 36
  • Posts: 1746
    • http://www.snewscms.com
[MOD] Highlight comments (sNews 1.4)
« Reply #2 on: January 25, 2006, 11:06:00 PM »

Quote from: bryn
also another useful function i have seen Luka is for the Admins comments to be featured in some way..either by highlighting them..insetting them..displaying an Admin logo..etc etc etc..mostly using an option involving css..but how do you grab Admins comments from the db to affect them when written?

get my drift..gettin sleepy here and probably not making sense ;D

Yes, that's also a neat option...

You know how we could slove that?
If you enter your password under name it automatically displays your name and style it differently...
Logged

George Antoniadis

  • Sr. Member
  • ****
  • Karma: 0
  • Posts: 479
[MOD] Highlight comments (sNews 1.4)
« Reply #3 on: January 26, 2006, 04:05:21 AM »

could be something like: username/password or username:password
or a secret word maybe instead of the password cause 95% of browsers save these kinda stuff and you don't want to get this out!!!

(why not a check if the dude that posted is logged in as the admin and if yes add something like: ^ before the username that is saved in the db? and then just if first char is ^ when displaying the comment it would flag it as an admin comment...)
and the only check would be dissallowing users to write ^ in the username! :P

(I'm not sure if I make sense I'm pretty sick! o_O)
Logged
How I feel like I'm starless, I'm ready to fade now.
And how I feel like I'm starless, I'm hopeless and greyed out.

bryn

  • sNews Dude
  • Hero Member
  • *****
  • Karma: 2
  • Posts: 939
    • http://www.cssugly.com
[MOD] Highlight comments (sNews 1.4)
« Reply #4 on: January 26, 2006, 06:57:48 AM »

sorry your not feeling well 'a'..get better soon mate :)

I found this:

http://wordpress.org/support/topic/27045

and this:

http://www.somefoolwitha.com/mallow
what ya think? we would need to add an admin email variable to check against right? ;D
Logged
Over 1,000 posts of joy, sNews is not only brilliant, but fun too! thanks guys :D

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4957
  • I'm a self-made man and worships my creator.
    • p-ahlqvist.com
[MOD] Highlight comments (sNews 1.4)
« Reply #5 on: January 26, 2006, 02:42:11 PM »

I have my admin comments highlited this way: http://p-ahlqvist.com/gb/gb.php It's done by having a admin commenting possibility while logged in. How, in the code, hehe I won't even try to... go into ;). But I think analyzerx idea seems like a good one. As I can unlock locked post's in my guestbook by adding ie "?a=q" after the URL, one should be able to post something as admin by adding something like that to the namefield, or....not ?

Just guessing here. The feature would be appriciated anyhow ;)
Logged
My sNews site
"It's only dead fish that goes with the flow... "
Updated, online again - Free designs

Mika

  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 9
  • Posts: 1408
    • http://www.ni5ni6.com/
[MOD] Highlight comments (sNews 1.4)
« Reply #6 on: June 09, 2006, 04:17:47 PM »

Highlighted comments, here i come :D

find in //COMMENTS
Quote
//COMMENTS
...
while ($r = mysql_fetch_array($result)) {
echo "<div class='comments'><p>" .cleanXSS($r['comment']). "</p>";
$date = date(s('comment_dt_format'), strtotime($r['time']));
echo "<p><img src='" .s('website'). "images/commentname.gif' alt='>' /> <b>" .cleanXSS($r['name']). "</b>";
if  (date("Y", strtotime($r['time'])) == 1999 OR s('display_comment_time') == "NO") {
$date = "";
} else {
echo " <img src='" .s('website'). "images/arrow.gif' alt='|' /> ";
echo $date;            
}
if (isset($_SESSION['Logged_In'])) { echo " <img src='" .s('website'). "images/arrow.gif' alt='|' /> "; ?>
         <a href="<? echo s('website'); ?>index.php?action=process&action=editcomment&commentid=<?php echo $r['id']; ?>"><? echo l('edit'); ?></a> <img src="<? echo s('website'); ?>images/arrow.gif" alt="|" /> <a href="<? echo s('website'); ?>index.php?action=process&task=deletecomment&articleid=<? echo $articleid; ?>&commentid=<? echo $r['id']; ?>"<? if_javascript_on(" onclick='return confirm(\"".l('warning_delete')."\");'"); ?>"><? echo l('delete_comment'); ?></a> <?
      } echo "</p></div>"; }
...
and add the blue code like this
Quote
//COMMENTS
...
$number = 1;
while ($r = mysql_fetch_array($result)) {
//change the colors to match your design, or make a switch for CSS class 'comments' (recommended)
$number % 2 == 0 ? $style="style='background-color: #FFFFFF'" : $style="style='background-color: #CCCCCC'";
echo "<div class='comments' ".$style."><p>" .cleanXSS($r['comment']). "</p>";
$date = date(s('comment_dt_format'), strtotime($r['time']));
echo "<p><img src='" .s('website'). "images/commentname.gif' alt='>' /> <b>" .cleanXSS($r['name']). "</b>";
if  (date("Y", strtotime($r['time'])) == 1999 OR s('display_comment_time') == "NO") {
$date = "";
} else {
echo " <img src='" .s('website'). "images/arrow.gif' alt='|' /> ";
echo $date;            
}
if (isset($_SESSION['Logged_In'])) { echo " <img src='" .s('website'). "images/arrow.gif' alt='|' /> "; ?>
         <a href="<? echo s('website'); ?>index.php?action=process&action=editcomment&commentid=<?php echo $r['id']; ?>"><? echo l('edit'); ?></a> <img src="<? echo s('website'); ?>images/arrow.gif" alt="|" /> <a href="<? echo s('website'); ?>index.php?action=process&task=deletecomment&articleid=<? echo $articleid; ?>&commentid=<? echo $r['id']; ?>"<? if_javascript_on(" onclick='return confirm(\"".l('warning_delete')."\");'"); ?>"><? echo l('delete_comment'); ?></a> <?
      } echo "</p></div>";
$number++;
}
...
« Last Edit: August 25, 2007, 03:09:57 AM by Phil Martin (Philmoz) »
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

Fred K

  • sNews Dude
  • ULTIMATE member
  • *****
  • Karma: 131
  • Posts: 2798
[MOD] Highlight comments (sNews 1.4)
« Reply #7 on: June 11, 2006, 04:45:49 PM »

hmm. Mika, I tried your mod but had to modify it slightly to fit my scenario and the funny thing is ... even numbers aren't printed. As you can see from this page, these sequentially entered test comments get numbers 1, 3 and 5. Not 1, 2 and 3 as I'd expect.

Here's how my code looks after my slight modification:
Quote
$result = mysql_query($query) or die(s('dberror'));
   $num = 1;
   while ($r = mysql_fetch_array($result)) {
   $num % 2 == 0 ? $style='even' :
   $style='talk';

         echo "<div class='comments $style'><p><span class='order'> #" .($offset + ($num++)).".</span> ".cleanXSS($r['comment']). "</p>";
         $date = date(s('comment_dt_format'), strtotime($r['time']));
         echo "<p><strong>" .cleanXSS($r['name']). "</strong>";
      if  (date("Y", strtotime($r['time'])) == 1999 OR s('display_comment_time') == "NO") {
         $date = "";
      } else {
         echo " ";
         echo $date;            
      }
      if (isset($_SESSION['Logged_In'])) { echo " <img src='" .s('website'). "images/arrow.gif' alt='|' /> "; ?>
         <a href="<? echo s('website'); ?>index.php?action=process&action=editcomment&commentid=<?php echo $r['id']; ?>"><? echo l('edit'); ?></a> <img src="<? echo s('website'); ?>images/arrow.gif" alt="|" /> <a href="<? echo s('website'); ?>index.php?action=process&task=deletecomment&articleid=<? echo $articleid; ?>&commentid=<? echo $r['id']; ?>"<? if_javascript_on(" onclick='return confirm(\"".l('warning_delete')."\");'"); ?>"><? echo l('delete_comment'); ?></a> <?
      } echo "</p></div>";
      $num++;
      }
Oh, wait, I just saw what may be the cause... The top part was written as recommended in your reply to my post on a similar topic and contains this bit:
Quote
<span class='order'> #" .($offset + ($num++)).".</span>
Which would clash with the last part (
} echo "</p></div>";
      $num++;
      }
) -- right? hmm, I'll try removing one of them, see what happens.
;D

Other than that, the comments highlight and comments number mods work great -- thanks a lot!

*** Edit ***
It worked, removing the "$num++" (or "number++" from Mika's original code) in the final section solved my problem. I now have a comment function that a) prints the order number of each comment and b) gives odd and even numbered comments different styles. Very nice. Now for the admin comment's style...
*** End edit ***
« Last Edit: August 25, 2007, 03:10:13 AM by Phil Martin (Philmoz) »
Logged

Mika

  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 9
  • Posts: 1408
    • http://www.ni5ni6.com/
[MOD] Highlight comments (sNews 1.4)
« Reply #8 on: June 11, 2006, 10:25:49 PM »

mea culpa mr. smith :D
i forgot to mention in your numbering thread that you might encounter some compatibility problems regarding highlighting mod.

odd numbering as a result to this
Quote
echo "<div class='comments $style'><p><span class='order'> #" .($offset + ($num++)).".</span> ".cleanXSS($r['comment']). "</p>";
should be resolved as follows
Quote
echo "<div class='comments $style'><p><span class='order'> #" .($offset + $num).".</span> ".cleanXSS($r['comment']). "</p>";
EDIT: regarding admin comments.. i'll test analyzerx's idea and post some code soon ;)
EDIT: a brand new admin comments mod is here
« Last Edit: August 25, 2007, 03:10:51 AM by Phil Martin (Philmoz) »
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

areyouami

  • Newbie
  • *
  • Karma: 3
  • Posts: 24
[MOD] Highlight comments (sNews 1.4)
« Reply #9 on: August 17, 2007, 05:42:07 PM »

Is this available in 1.6?
Logged

centered

  • Guest
[MOD] Highlight comments (sNews 1.4)
« Reply #10 on: August 17, 2007, 06:50:30 PM »

I got excited, I thought it was another 1.4 lover....

To my dismay... lol .. umm ya sure I can release it for 1.6 as a full file no code comments showing... j/k!!

Did you try searchign for it?
I found this one for 1.5:
(updated link) http://snewscms.com/forum/index.php/topic,3259.0.html

I am sure *most* of the code can be applied for 1.6
« Last Edit: February 16, 2012, 02:34:57 PM by Keyrocks »
Logged