Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2] 3

Author Topic: [ADDON] Article Rating [sNews 1.5]  (Read 27566 times)

Vinoth

  • Newbie
  • *
  • Karma: 1
  • Posts: 33
[ADDON] Article Rating [sNews 1.5]
« Reply #15 on: May 14, 2007, 08:51:11 PM »

I am using sNews 1.5.31 and the mod does not work, i have done exactly what the author has implied but no successful results.

I do not get any error, but nothing is displayed when viewing the page.
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
[ADDON] Article Rating [sNews 1.5]
« Reply #16 on: May 14, 2007, 09:24:00 PM »

Quote from: Vinoth
I am using sNews 1.5.31 and the mod does not work, i have done exactly what the author has implied but no successful results.

I do not get any error, but nothing is displayed when viewing the page.
near top of snews.php, is

Quote
//error_reporting(E_ALL ^ E_NOTICE);
error_reporting(0);
make it like the following, temporarily...
Quote
error_reporting(E_ALL ^ E_NOTICE);
//error_reporting(0);
and see if any errors are displayed.
Logged
Of all the things I have lost, it is my mind that I miss the most.

Vinoth

  • Newbie
  • *
  • Karma: 1
  • Posts: 33
[ADDON] Article Rating [sNews 1.5]
« Reply #17 on: May 14, 2007, 09:36:06 PM »

wonderful and thanx for the help. i did notice the errors and rectified it.

The error was i have named the directory and the filename differently from what it appears in your coding.

Thanx for the help and have u coded down any other hacks or mods.
Logged

Vinoth

  • Newbie
  • *
  • Karma: 1
  • Posts: 33
[ADDON] Article Rating [sNews 1.5]
« Reply #18 on: May 14, 2007, 09:42:50 PM »

One more question where are the CSS files used. should the user create based on the classes and ids given or it is some where else.
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
[ADDON] Article Rating [sNews 1.5]
« Reply #19 on: May 14, 2007, 09:55:11 PM »

Quote from: Vinoth
One more question where are the CSS files used. should the user create based on the classes and ids given or it is some where else.
see first post for a list of classes used in the script, and what they affect. (I think I have them all listed there...)
It is up to the user to style however they choose.
Logged
Of all the things I have lost, it is my mind that I miss the most.

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
[ADDON] Article Rating [sNews 1.5]
« Reply #20 on: May 14, 2007, 09:58:52 PM »

Quote from: Vinoth
Thanx for the help...
no probs...
Quote from: Vinoth
... and have u coded down any other hacks or mods.
one or two :D
Logged
Of all the things I have lost, it is my mind that I miss the most.

Vinoth

  • Newbie
  • *
  • Karma: 1
  • Posts: 33
[ADDON] Article Rating [sNews 1.5]
« Reply #21 on: May 14, 2007, 11:07:31 PM »

I have mailed you a letter, since i cannot PM coz of some problems with my browser or software.
Logged

snapplekid13

  • Newbie
  • *
  • Karma: 0
  • Posts: 23
[ADDON] Article Rating [sNews 1.5]
« Reply #22 on: June 29, 2007, 12:35:23 AM »

Well I tried uploading into 1.6 and everything worked except that when I vote it gives me the message saying I did but it doesn't show up! http://towncook.com/baking/how-to-bake-a-flat-cake-and-other-tips/ is the article I'm trying.
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
[ADDON] Article Rating [sNews 1.5]
« Reply #23 on: June 29, 2007, 01:13:46 AM »

Check to make sure you have the right paths set in the top section of rater.php.

-- images didn't show for me, so I suspect this may have something to do with it.
Logged
Of all the things I have lost, it is my mind that I miss the most.

snapplekid13

  • Newbie
  • *
  • Karma: 0
  • Posts: 23
[ADDON] Article Rating [sNews 1.5]
« Reply #24 on: June 29, 2007, 02:21:35 AM »

I changed them and it still won't show the images...

How do I name the images?

0 stars = star_00.gif or 00.gif?
0.5 stars= star_05.gif or 05.gif

etc etc...
EDIT: Figured it out all is good everything works :)
Logged

NenadX

  • Newbie
  • *
  • Karma: 0
  • Posts: 3
[ADDON] Article Rating [sNews 1.5]
« Reply #25 on: July 31, 2007, 12:04:53 AM »

Quote from: snapplekid13
I changed them and it still won't show the images...

How do I name the images?

0 stars = star_00.gif or 00.gif?
0.5 stars= star_05.gif or 05.gif
0 stars = 00star.gif
0.5 stars= 05star.gif
1 stars= 1star.gif

I put one paragraph at the end:

Code: [Select]
include("rater/rater.php");echo '<p>..........</p>'; ///place rated articles here.instead of:

Code: [Select]
include("rater/rater.php"); ///place rated articles here.to create separator between articles.
« Last Edit: August 23, 2007, 01:55:41 AM by Phil Martin (Philmoz) »
Logged

line

  • Newbie
  • *
  • Karma: 1
  • Posts: 10
Re: [ADDON] Article Rating [sNews 1.5]
« Reply #26 on: November 10, 2007, 07:17:38 PM »

I'm no good with codes.

Just an inquiry. I'm using sNews 1.6 MEMU compiled by Keyrocks..
Will this work with that release? I looked for the infoline but don't know what to do there.

Thanks in advance.
Logged
"Living is easy with eyes closed. Misunderstanding all you see" - strawberry fields forever

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: [ADDON] Article Rating [sNews 1.5]
« Reply #27 on: November 10, 2007, 08:12:16 PM »

I have not applied this mod at all but... after looking it over... I suggest it should work with 1.6 MEMU. All of the reference points you need to look for are the same in 1.5.31 and 1.6.0 default packages... and the the same again in the MEMU package's engine file.

Philmoz's directions say to put the new script into a new PHP file in a separate directory in the site root. Since the MEMU package uses the mods folder to contain mods and addons... I would put it in there.

Create your new folder in the mods folder and call it rater. Then add the main script to the new file and save it into the rater folder as rater.php. Your images will also go in the same folder.

Then you add the strings to the 2 locations in the center function, as shown. Notice that both mod strings have the path to the file within them - rater/rater.php. With the rater folder now in the mods folder... you need to add the mods folder to the file-path in both strings... to look like - mods/rater/rater.php. And it should work as expected.  :)
« Last Edit: November 10, 2007, 08:20:40 PM by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

line

  • Newbie
  • *
  • Karma: 1
  • Posts: 10
Re: [ADDON] Article Rating [sNews 1.5]
« Reply #28 on: November 10, 2007, 09:00:01 PM »

WoW!  :o

Thanks Keyrocks!
You made it clearer.
Got to test it.

Thanks again for the quick response. I thought I have to wait for half a day to receive a reply. And a reply in 55 minutes.

Salamat!



UPDATE:

Now working!  ;D
« Last Edit: November 10, 2007, 10:07:47 PM by line »
Logged
"Living is easy with eyes closed. Misunderstanding all you see" - strawberry fields forever

azad

  • Newbie
  • *
  • Karma: 0
  • Posts: 21
Re: [ADDON] Article Rating [sNews 1.5]
« Reply #29 on: December 19, 2007, 12:40:48 PM »

Version 1.00

Inspired by this original post
http://snewscms.com/forum/index.php?topic=2495.0
and my concerns about that script mentioned... so, here is my version.

Produces output showing user ratings of articles.
-- restricts voting based on first 3 blocks of ip... limits the liklihood of multiple votes.
-- stores ip numbers per article as text files which are retrieved on call.
-- quantity of ip numbers stored is configurable. Oldest is dropped from the storage file once the quantity is exceeded
-- calculations are performed at voting time only (as opposed to every time the other script is called)
-- stores results per article as an array file.


Images and naming convention.
Will require 11 images for 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5
Name the images with a prefix.. eg star_
Multiply the rating number(see above) by 10 and append to the prefix eg star_15, star_40, star_05, star_00
Don't forget to do the file extension :)  star_15.gif 

css classes in script, and use. (information only)
.snews_rate_wrap   wrapper around all rating content.
.rating            surrounds the rating image, and filler text.
.reviewcount      text and numbers inside the filler text
.rating_button      is the form button for submission.
.rate_item         for the text above the image display
.rate_article_name   for the article name when displayed as part of the rate_item area.

Onwards...
Make a new file.. eg rating.php (must have the php extension) and save.
Copy the code below, and paste into the new file and save.
Place this new file in a new directory in snews root .
Place your image set directory in this same new directory
Alter the user settings...

Code: [Select]
<?php
$ratingsOn
=1;
if(
$ratingsOn==1){
//inspired by rating application from http://www.gr0w.com/articles/code/php_5_star_rating_system_using_hreview/index.php
// Completely rewritten for use in sNews1.5 by philmoz
////////////////////////////////////////
// User settings. //
$sNews_rate_dir ='rating/';   // location of this script.
$sNews_rate_dir_images 'gnomes/';  //name of directory with the image set to use in it.
$sNews_rate_image_prefix 'gnomes-';  // name your images with a prefix, (eg, star_ for star_00.png). Allows you to swap image set quickly.
$sNews_rate_rank_descriptor "gnomes"// describes the means of voting... eg, stars, bullet, houses... whatever the images imply
$sNews_rate_image_ext 'gif';    // change to jpg, gif, png as required for your images.
$sNews_rate_button 'Please Rate'// text for rating form button
$sNews_EOL "\n";   //(may need to alter to  '\r\n' if that is what your system requires.)
$max_ip_stored 5;  // maximum ip numbers to be stored for each rating.Adjust as comfortable. Probably no more than 100
$sNews_not_rated_txt="Not rated";
// Messages -- Write as incomplete messages as they will be completed in the script.
$sNews_not_rated_msg 'No rating for '// will have the article name appended further down.
$sNews_already_rated_msg 'It appears you have already rated ';
$sNews_thank_you_msg 'Thank you for rating '// will have the article name appended further down.
$sNews_not_selected_msg ='You have not selected a rating value for ';// will have the article name appended further down.
// other text
$sNews_rate_generic_text 'this item'// in the event that the article name fails to arrive.
////*********///
// for rated articles, and for short displayed articles. Alter html only.
$sNews_rated_heading='<p class="rate_item"><span class="rate_article_name">'.$sNews_item_name.'</span> rated by viewers as:-</p>';
// for unrated full articles.  Alter html only.
$sNews_unrated_heading'<p class="rate_item">Please rate <span class="rate_article_name">'.$sNews_item_name.'</span></p>';
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//System vars //
$sNews_rate_results=$sNews_rate_dir.'results.res.php'// results file.
$sNews_rate_ipfile=$sNews_rate_dir.'item_'.$sNews_rate_id.".rating"// unique ip files.
if(!isset($sNews_rate_id)) {$sNews_rate_id='1';}
if(!isset(
$sNews_item_name)) {$sNews_item_name=$sNews_rate_generic_text;}
if (
file_exists($sNews_rate_results)){include($sNews_rate_results);}
//set vars to initial values.////////////////////
$sNews_rate_txt ='';
$sNews_stars ="";
$sNews_rate_txt="";
$rate_rating=0;
$rate_value=0;
$rater_msg="";
$sNews_rate_images=$sNews_rate_dir.$sNews_rate_dir_images.$sNews_rate_image_prefix;
////START WORKING/////
$rater_ip2 $rater_ip getenv("REMOTE_ADDR"); //voters ip
$ip_sepsexplode('.',$rater_ip);$rater_ip =$ip_seps[0].".".$ip_seps[1].".".$ip_seps[2].".";//truncate ip to first 3 blocks.
if (is_file($sNews_rate_ipfile)) {
$rate_array=explode($sNews_EOL,file_get_contents($sNews_rate_ipfile));
$count_rates=count(array_count_values($rate_array));
if (
in_array($rater_ip,$rate_array)) {
$rated='true';
$rater_msg=$sNews_already_rated_msg;
}}
// posting a rating. // voting form should be unavailable if already ip identified.
if (isset($_REQUEST["sNewsrate".$sNews_rate_id]) && !isset($_REQUEST["rating_".$sNews_rate_id])){
$rater_msg$sNews_not_selected_msg;
$rated='false';
}elseif(
$rated=='false'&& isset($_REQUEST["sNewsrate".$sNews_rate_id])){
if (!isset($rating_results[$sNews_rate_id])){$rate_value=0;$rate_numbers=0;$rate_total_score=0;
}else{
$rate_numbers $rating_results[$sNews_rate_id][0];$rate_value $rating_results[$sNews_rate_id][1];$rate_total_score$rating_results[$sNews_rate_id][2];}
$new_numbers=$rate_numbers+1;
$rater_vote $_REQUEST["rating_".$sNews_rate_id];
$new_score=$rate_total_score+$rater_vote[0];
$new_values=$new_score/$new_numbers;
if ($new_values>(intval($new_values)+0.85)) {$new_values=intval($new_values)+1;// high biased round up
}elseif ($new_values<(intval($new_values)+0.35)){$new_values=intval($new_values);// high biased round down
}else{$new_values=intval($new_values)+0.5; //if in range of  x.35>Vote>x.85 make it x.5

$rating_results[$sNews_rate_id][0]=$new_numbers;
$rating_results[$sNews_rate_id][1]=$new_values;
$rating_results[$sNews_rate_id][2]=$new_score;
//write results file.
$writer "<?php\n";
foreach (array_keys($rating_results)as $key){
$writer .= "\$rating_results[$key]=array('".$rating_results[$key][0]."','".$rating_results[$key][1]."','".$rating_results[$key][2]."');\n";}
$writer .= "?>
\n";
// file_put_contents($sNews_rate_results,$writer); // file_put_contents is php5 only...
$f=@fopen($sNews_rate_results,"w+");
   fwrite($f,$writer);
   fclose($f);
//write ip file.
if (($max_ip_stored)<=$count_rates){  // checks for max ips
array_shift($rate_array);
$count_rates=$count_rates-1;
}
$rate_array[$count_rates]=$rater_ip;
// file_put_contents($sNews_rate_ipfile, implode($sNews_EOL, $rate_array));
$f=@fopen($sNews_rate_ipfile,"w+");
$write_ips = implode($sNews_EOL, $rate_array);
   fwrite($f,$write_ips);
   fclose($f);
$rater_msg= $sNews_thank_you_msg;
$rated='true';
}

// SHOW RATING RESULT
if (!isset($rating_results[$sNews_rate_id])|| !is_file($sNews_rate_ipfile)){
$rate_value=0;$rate_numbers=0;
}else{
$rate_numbers = $rating_results[$sNews_rate_id][0];
$rate_value = $rating_results[$sNews_rate_id][1];}
if ($rate_value <= 0 || !isset($rating_results[$sNews_rate_id])){
$sNews_rate_txt=$sNews_not_rated_txt;
$digits = '00';}else{
$sNews_rate_txt = $rate_value;}
if ($rate_value>0){
if ($rate_value=='0.5' ){$digits = '05';}
else{$digits = $rate_value*10;}
}
// Assign image
$sNews_stars = $sNews_rate_images.$digits.'.'.$sNews_rate_image_ext;
// Output
$echo= $sNews_EOL.$sNews_EOL.'<div class="snews_rate_wrap">'.$sNews_EOL;
$echo.= '<form method="post" action="'.db('website').$categorySEF.'/'.$r['seftitle'].'/">';
if($rated=="true" && isset($rating_results[$sNews_rate_id])){$echo.= $sNews_rated_heading;}else{$echo.= $sNews_unrated_heading;}
$echo.= '<div>';
$echo.= '<span  class="rating"><img src="'.$sNews_stars.'?x='.uniqid((double)microtime()*1000000,1).'" alt="'.$rate_value.' stars" /> Average rating:~
</span><span class="reviewcount">'.$sNews_rate_txt.'</span>';
if ($sNews_rate_txt!=$sNews_not_rated_txt){
$echo.= ' <span class="rating">'.$sNews_rate_rank_descriptor.' from </span><span class="reviewcount">'.$rate_numbers.'</span><span class="rating"> votes.</span>
';}
$echo.= '</div>'.$sNews_EOL;
if($rater_msg=="" && $rater_msg!=$sNews_already_rated_msg && $rated=="false" ||$rater_msg==$sNews_not_selected_msg){
$echo.= '<div style="clear:both;">';
$echo.= '<label for="rate1_'.$sNews_rate_id.'"><input type="radio" value="0" name="rating_'.$sNews_rate_id.'[]" id="rate1_'.$sNews_rate_id.'" />Hmm?</label> '.$sNews_EOL;
$echo.= '<label for="rate2_'.$sNews_rate_id.'"><input type="radio" value="1" name="rating_'.$sNews_rate_id.'[]" id="rate2_'.$sNews_rate_id.'" />Poor</label> '.$sNews_EOL;
$echo.= '<label for="rate3_'.$sNews_rate_id.'"><input type="radio" value="2" name="rating_'.$sNews_rate_id.'[]" id="rate3_'.$sNews_rate_id.'" />Fair</label> '.$sNews_EOL;
$echo.= '<label for="rate4_'.$sNews_rate_id.'"><input type="radio" value="3" name="rating_'.$sNews_rate_id.'[]" id="rate4_'.$sNews_rate_id.'" />Good</label> '.$sNews_EOL;
$echo.= '<label for="rate5_'.$sNews_rate_id.'"><input type="radio" value="4" name="rating_'.$sNews_rate_id.'[]" id="rate5_'.$sNews_rate_id.'" />Very Good</label> '.$sNews_EOL;
$echo.= '<label for="rate6_'.$sNews_rate_id.'"><input type="radio" value="5" name="rating_'.$sNews_rate_id.'[]" id="rate1_'.$sNews_rate_id.'" />Excellent</label> '.$sNews_EOL;
$echo.= '<input type="hidden" name="rs_id" value="'.$sNews_rate_id.'" />'.$sNews_EOL;
$echo.= '<input class="rating_button"type="submit" name="'.'sNewsrate'.$sNews_rate_id.'" value="'.$sNews_rate_button.'" />'.$sNews_EOL;
$echo.= '</div>'.$sNews_EOL;}
if($rater_msg!="") $echo.= '<div style="clear:both;"><p class="rate_item">'.$rater_msg.'<span class="rate_article_name">'.$sNews_item_name.'</span> ('.$rater_ip2.')</p></div>'.$sNews_EOL;
$echo.= '</form>'.$sNews_EOL;
$echo.= '</div>'.$sNews_EOL.$sNews_EOL;
echo $echo;
}
?>
To plug into snews, locate
//CENTER
then find the case ($tag != 'readmore' .. after infoline
Code: [Select]
if ($infoline == true) {
foreach ($tag as $tag) {
...[snipped for brevity]...
case ($tag != 'readmore' && $tag != 'comments' && $tag != 'edit'): echo $tag; break;
}
}
}
else if ($
and add the extra
Code: [Select]
if ($infoline == true) {
foreach ($tag as $tag) {
...[snipped for brevity]...
case ($tag != 'readmore' && $tag != 'comments' && $tag != 'edit'): echo $tag; break;
}
/*rating script -- */ }$sNews_rate_id=$r['id'];$sNews_item_name=$r['title'];$rated="true";include("rater/rater.php"); ///place rated articles here.
}
else if ($
Alter "rater/rater.php" to your rating directory, and the name you called the file...
Then,
A bit further down,
Code: [Select]
if ($infoline == true) {
$tag = explode(',', tags('infoline'));
...[snipped for brevity]...
default: echo $tag;
}
}
}
else if ($_SESSION[db('website').'Logged_In'] == 'True') {echo '<p>'.$edit_link.'</p>';}
}
}
and alter the end bit to this...
Code: [Select]
if ($infoline == true) {
$tag = explode(',', tags('infoline'));
...[snipped for brevity]...
default: echo $tag;
}
/*rating script -- */ }$sNews_rate_id=$r['id'];$sNews_item_name=$r['title'];$rated="false";include("rater/rater.php");
}
else if ($_SESSION[db('website').'Logged_In'] == 'True') {echo '<p>'.$edit_link.'</p>';}
}
}
Again, alter "rater/rater.php" to your rating directory, and the name you called the file...

Some graphic sets can be downloaded from my site... http://www.fiddlenfolk.com/downloads/downloads/
Updates:~
Tweaked instructions -- no code change



Hi,

I am using sNews 1.6 and i like your Star Rating Article but friend some thing i don't remember

there is a rate.php code:
// User settings. //
$sNews_rate_dir ='rate/';   // location of this script.
$sNews_rate_dir_images = 'gnomes/';  //name of directory with the image set to use in it.
$sNews_rate_image_prefix = 'gnomes-';  // name your images with a prefix, (eg, star_ for star_00.png). Allows you to swap image set quickly.
$sNews_rate_rank_descriptor = "gnomes"; // describes the means of voting... eg, stars, bullet, houses... whatever the images imply

you notice in this above code some area are in red color. so please tell me what will i replace in these palaces

Sorry my enlish is not well

Thank you
Logged
Pages: 1 [2] 3