hi every one..
i would like to ask this:
can i show published news ordered by the number of votes?
thanks..


![]() |
| | Thread Tools | Display Modes |
| |||
|
hi every one.. i would like to ask this: can i show published news ordered by the number of votes? thanks.. |
| ||||
|
Open /index.php and go to line 35: Code: if(!isset($_REQUEST['search'])){$search->orderBy = "link_published_date DESC";} Code: if(!isset($_REQUEST['search'])){$search->orderBy = "link_votes DESC";} |
| |||
|
thanks rewine.... another question can i mix link_published_date and link_votes? |
| ||||
|
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.
|
| ||||
|
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. |
| ||||
|
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 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";} 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"; Code: $search->fitlerToStatus = "published"; 3. ========== libs/search.php near line 50 find: Code: if ($this->filterToTimeFrame == 'today') { 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) ";
} If it works for you, remember me! If not, we never met .Cheers from Brookhaven! Quote:
|
| ||||
|
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 |
| ||||
|
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! |
![]() |
| 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 |