how to order published news by number of votes?

Register an Account
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 02-19-2008, 02:03 PM
Constant Pligger
Pligg Version: 9.9
Pligg Template: yget mod
 
Join Date: Oct 2007
Posts: 162
hi every one..

i would like to ask this:

can i show published news ordered by the number of votes?


thanks..
Reply With Quote
  #2 (permalink)  
Old 02-19-2008, 02:36 PM
redwine's Avatar
Pligg Donor
Pligg Version: 9.8
Pligg Template: custom templat
 
Join Date: Jul 2007
Location: Canada
Posts: 216
Open /index.php and go to line 35:

Code:
if(!isset($_REQUEST['search'])){$search->orderBy = "link_published_date DESC";}
Change it to:

Code:
if(!isset($_REQUEST['search'])){$search->orderBy = "link_votes DESC";}
Reply With Quote
  #3 (permalink)  
Old 02-19-2008, 03:19 PM
Constant Pligger
Pligg Version: 9.9
Pligg Template: yget mod
 
Join Date: Oct 2007
Posts: 162
thanks rewine.... another question

can i mix link_published_date and link_votes?
Reply With Quote
  #4 (permalink)  
Old 02-19-2008, 03:44 PM
gen3ric's Avatar
Casual Pligger
Pligg Version: 9.X
Pligg Template: Custom
 
Join Date: Jul 2007
Location: Atlanta, GA
Posts: 91
This is a good question, I've been curious if it was possible to order the front page by number of votes in the last X number of hours.
Reply With Quote
  #5 (permalink)  
Old 02-19-2008, 05:52 PM
gen3ric's Avatar
Casual Pligger
Pligg Version: 9.X
Pligg Template: Custom
 
Join Date: Jul 2007
Location: Atlanta, GA
Posts: 91
Hey redwine, what I think would be cool is if the published stories sorted by # of votes over the past 4 hours. That way, every 4 hours, the order of the front page will be determined by the stories that received the most votes during that 4 our time period.

The reason I don't want to just sort them by number of votes is because I don't want an entry that was submitted 3 days ago and has since received a bunch of votes to still be at the top.
Reply With Quote
  #6 (permalink)  
Old 06-17-2008, 03:30 AM
keg01's Avatar
Pligg Donor
Pligg Version: 1.0.0
Pligg Template: exp realnews
 
Join Date: Oct 2007
Location: Atl
Posts: 74
Older thread but we never give up, do we?

@lacasuela: If you want to sort by both published date and votes, just decide which takes precendence and do one of the following in the sql statement referenced by redwine:

Code:
 link_published_date DESC, link_votes DESC
 link_votes DESC, link_published_date DESC
@gen3ric

What a provocative question! I couldn't help but take a look. I think there are potential issues with this approach like what happens if there's no published links in the 4 hour interval? Blank home page!

Maybe not an issue with your volumes. In any case, I think this will do it in 3 steps (based on 9.8.2) ...

1. ==========
index.php line 34 replace:
Code:
if(!isset($_REQUEST['search'])){$search->orderBy = "link_published_date DESC";}
with:
Code:
if(!isset($_REQUEST['search'])){$search->orderBy = "link_votes DESC, link_published_date DESC";}

2. ==========
index.php near line 46 insert:
Code:
$search->filterToTimeFrame = "custom";
after existing line:
Code:
$search->fitlerToStatus = "published";

3. ==========
libs/search.php near line 50 find:
Code:
if ($this->filterToTimeFrame == 'today') {
and insert above that entry this conditional:

Code:
                if ($this->filterToTimeFrame == 'custom') {
                        $tsdt = date('YmdHis', strtotime("- 4 hours"));
                        $fsdt = date('YmdHis', strtotime("now"));
                        $from_where .= " AND (link_published_date >= $tsdt AND link_published_date <= $fsdt) ";
                }
Note that this is definitely a hack (hard-coded custom interval is not elegant) and untested. But I think it changes your default published links tab to only display items published in the past 4 hours sorted by highest vote getters. Neat idea ... call it your "what-have-you-done-for-me-lately" filter ...

If it works for you, remember me! If not, we never met .

Cheers from Brookhaven!

Quote:
Originally Posted by gen3ric View Post
Hey redwine, what I think would be cool is if the published stories sorted by # of votes over the past 4 hours. That way, every 4 hours, the order of the front page will be determined by the stories that received the most votes during that 4 our time period.

The reason I don't want to just sort them by number of votes is because I don't want an entry that was submitted 3 days ago and has since received a bunch of votes to still be at the top.
Reply With Quote
  #7 (permalink)  
Old 06-17-2008, 12:45 PM
keg01's Avatar
Pligg Donor
Pligg Version: 1.0.0
Pligg Template: exp realnews
 
Join Date: Oct 2007
Location: Atl
Posts: 74
As a trouble-shooting tool, I wanted sql to compare against the modified pligg code I suggested. If you hack the code as proposed, here is some sql I think gets the same link result set in a different way and might be helpful in testing:

Code:
SELECT 
link_id, 
link_author, 
link_votes, 
link_published_date, 
link_title, link_summary 
FROM pligg_links 
WHERE 
link_published_date > now() - INTERVAL 4 HOUR AND
link_status='published' 
ORDER BY link_votes DESC, link_published_date DESC
Reply With Quote
  #8 (permalink)  
Old 01-04-2009, 12:02 AM
keg01's Avatar
Pligg Donor
Pligg Version: 1.0.0
Pligg Template: exp realnews
 
Join Date: Oct 2007
Location: Atl
Posts: 74
For those stumbling on this thread beware! There is a serious flaw in this approach that will adversely affect your seo. Unless your site is crawled within the interval you define in the custom search, those items become unreachable via web search results because they are never crawled - not good!

If anyone has worked with "gravity"-type sorting of published items and has an approach that doesn't have this type of problem, this would be a great place to share!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change number of votes using the news management gnalkit Questions and Comments 5 05-19-2011 03:34 AM
News based on Clicks instead of Votes mde05 Questions and Comments 2 01-14-2008 09:32 AM
[Fixed] Published news link in sidebar links to queued news mbs348 Questions and Comments 2 03-01-2007 06:56 PM
i don't understand how news get published ddayn Questions and Comments 1 02-16-2007 10:51 AM
published news sort order williamboliver Questions and Comments 4 01-05-2006 04:32 AM


Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development