Forum Index
RegisterSearchFAQMemberlistUsergroupsLog in
Most populair news (views x rating)

 
Reply to topic    Forum Index » Suggestions View previous topic
View next topic
Most populair news (views x rating)
Author Message
astrostart



Joined: 11 Feb 2007
Posts: 124
Location: The Netherlands

Post Most populair news (views x rating) Reply with quote
I want to make a page which shows the ten most populair news (like a list)



The rating should be as followed:



... views x ... Ajax rating = .... score



For instance. An article has been seen 500 times and has an Ajax rating of 5 then the score would be 2500!



I want to list the ten newsmessages with the highest score of the last 14 days. So when a newsarticle is 14 days old and its on the 1st place, it will fall out of the charts at the 15th day.



--- EXAMPLE ---



Place. Title newsarticle (score)



1. Senators asking for more money (9194)

2. Cutenews is great (8274)

3. FI-DD's hacks are greater (7052)

4. Blabla (4972)

5. .... (....)

6.

7.

8.

9.

10. The end (2593)



-------------------------------------



Is something like that possible? It would be so awesome!

_________________
My site: http://www.astrostart.nl | Thanks to everyone here who has helped me!
Sat Apr 07, 2007 10:37 am View user's profile Send private message Visit poster's website
Guest








Please login to hide the ads.

FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2736
Location: Germany

Post Reply with quote
Open plugins/etc.php and add this at the end of the file above the last ?>:

Code:
function cn_ranking($days, $places){

global $sql;



foreach($sql->select(array('table' => 'news', 'where' => array("date > ".(time() - (86400 * $days))))) as $row){

   $points = round(($row['views'] * ($row['rating']/$row['votes'])), 0);

   $ranking[$points]['views'] = $row['views'];

   $ranking[$points]['rating'] = $row['rating'];

   $ranking[$points]['votes'] = $row['votes'];

   $ranking[$points]['link'] = cute_get_link($row);

   $ranking[$points]['title'] = $row['title'];

}



krsort($ranking);



$i = 1;



$output = '<table><tr><td>Place</td><td>Link</td></tr>';



foreach($ranking as $points => $value){

   if($i <= $places){

   

      $output .= '<tr><td>'.$i.'</td><td><a href="'.$value['link'].'">'.$value['title'].' ('.$points.')</a></td></tr>';

   

      $i++;

      

   }

}

$output .= '</table>';



return $output;



}




Then add this where you want to show the list:

Code:
echo cn_ranking($days = 14, $places = 10);

Tue Apr 10, 2007 6:35 pm View user's profile Send private message
Ramon



Joined: 12 Oct 2005
Posts: 462
Location: Hoogeveen, NL

Post Reply with quote
_O_



You should add this to the additional downloads section Smile

_________________
Wed Apr 11, 2007 12:45 am View user's profile Send private message Visit poster's website
scottdallas



Joined: 04 May 2006
Posts: 1843
Location: US

Post Reply with quote
Yeah that's really cool. So you're the PHP master, now the AJAX master, and also the math master?

_________________
www.scottdizzle.com uses cnr Smile
last update: 07-22-08: 8:30 pm
Wed Apr 11, 2007 1:42 am View user's profile Send private message Visit poster's website AIM Address
astrostart



Joined: 11 Feb 2007
Posts: 124
Location: The Netherlands

Post Reply with quote
I have no words... I'm speechless!



This is exactly what I had in mind! Wow! It's so great!



Thank you, FI-DD!!! Very Happy

_________________
My site: http://www.astrostart.nl | Thanks to everyone here who has helped me!
Wed Apr 11, 2007 1:28 pm View user's profile Send private message Visit poster's website
astrostart



Joined: 11 Feb 2007
Posts: 124
Location: The Netherlands

Post Reply with quote
http://www.astrostart.nl/populair.php



A showcase of this new addition to Cutenews!

_________________
My site: http://www.astrostart.nl | Thanks to everyone here who has helped me!
Wed Apr 11, 2007 2:14 pm View user's profile Send private message Visit poster's website
itzzmesur



Joined: 08 Feb 2007
Posts: 35

Post is there possiblity to restrict the categories in the utilit Reply with quote
nice one ,



How to restrict the categories.....let's say i just want the top news from 3-4 categories from whole of 10 categories
Tue May 08, 2007 9:04 am View user's profile Send private message
alfred_rade



Joined: 01 Dec 2007
Posts: 24
Location: Buenos Aires

Post FATAL ERROR!!! Reply with quote
The plugin works perfect, until I recieve this message in my index page:

[b]Fatal error: Call to undefined function cn_ranking() in /home/diariola/public_html/index.php on line 471[/b]

LINE 471 SAYS:
<?PHP
cn_ranking($days = 14, $places = 10);
?>


I try everything that I could know. I'm stuck now!

Please, HELP! what could it be?
Wed Feb 13, 2008 6:46 pm View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2736
Location: Germany

Post Reply with quote
Head.php must be included in index.php.
Fri Feb 15, 2008 4:15 pm View user's profile Send private message
acateoN



Joined: 12 Feb 2008
Posts: 47

Post Reply with quote
Thanks for the top 10 script but I get an annoying error:
Top 10

Warning: Division by zero in /share/HDB_DATA/Qweb/xpl.se/plugins/etc.php on line 303
But the script works just fine, the top 10 news is shown beneath it.
Line 303 says:
$points = round(($row['views'] * ($row['rating']/$row['votes'])), 0);
Wed Feb 20, 2008 3:29 pm View user's profile Send private message
scottdallas



Joined: 04 May 2006
Posts: 1843
Location: US

Post Reply with quote
Does this fix you?

http://english.cutenews.ru/forum/division-by-zero-t1010.html#5499

_________________
www.scottdizzle.com uses cnr Smile
last update: 07-22-08: 8:30 pm
Thu Feb 21, 2008 6:12 am View user's profile Send private message Visit poster's website AIM Address
acateoN



Joined: 12 Feb 2008
Posts: 47

Post Reply with quote
Unfortanetly it did not.
Same error still. : /
Fri Feb 22, 2008 10:38 pm View user's profile Send private message
alfred_rade



Joined: 01 Dec 2007
Posts: 24
Location: Buenos Aires

Post Reply with quote
head.php it was included in index.php and my rating not working
Mon Feb 25, 2008 7:14 pm View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2736
Location: Germany

Post Re: FATAL ERROR!!! Reply with quote
alfred_rade wrote:
The plugin works perfect, until I recieve this message in my index page:

So it worked before? Then you must have changed something because a script doesn't stop on its own just like that.

And it's impossible to see the error message although you have correctly included head.php because head.php loads all plugins including etc.php which contains the cn_ranking() function. So somewhere you made a mistake. Don't know where...
Wed Feb 27, 2008 8:11 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    Forum Index » Suggestions All times are GMT + 1 Hour
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum



Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Music Lyrics.