New Mod -- Display related stories

Register an Account
Reply
 
Thread Tools Display Modes
  #31 (permalink)  
Old 03-15-2007, 05:18 PM
Casual Pligger
 
Join Date: Nov 2006
Posts: 41
i used this
Quote:
function related_stories($storyid, $related_tags, $category){
// this returns similar stories based on tags in common and in the same category

global $db;
$related_tags="'".str_replace(", ","', '",$related_tags)."'"; // This gives us the proper string structure for IN SQL statement
// Select 10 stories that share tags with the current story and order them by number of tags they share

// $sql = "SELECT ".table_links.".link_title, ".table_links.".link_title_url, COUNT( ".table_tags.".tag_link_id ) AS relevance, ".table_tags.".tag_link_id FROM ".table_tags.", ".table_links." WHERE ".table_tags.".tag_words IN ( ".$related_tags." ) AND ".table_tags.".tag_link_id = ".table_links.".link_id AND ".table_links.".link_status = 'published' AND NOT ".table_links.".link_id = ".$storyid;
$sql = "SELECT ".table_links.".link_title, ".table_links.".link_title_url, COUNT( ".table_tags.".tag_link_id ) AS relevance, ".table_tags.".tag_link_id FROM ".table_tags.", ".table_links." WHERE ".table_tags.".tag_words IN ( ".$related_tags." ) AND ".table_tags.".tag_link_id = ".table_links.".link_id AND ".table_links.".link_id != ".$storyid;


//comment the following line out if you want this to work accross categories
// $sql.= " AND ".table_links.".link_category = ".$category;
$sql.= " GROUP BY ".table_tags.".tag_link_id, ".table_links.".link_title, ".table_links.".link_title_url ORDER BY relevance DESC LIMIT 10";
// echo $sql;
$related_stories = mysql_query($sql);
$related_story = array();
while ($rows = mysql_fetch_array ($related_stories, MYSQL_ASSOC)) array_push ($related_story, $rows);
return $related_story;
}
Reply With Quote
  #32 (permalink)  
Old 03-15-2007, 06:34 PM
Constant Pligger
 
Join Date: Feb 2007
Posts: 226
Thanks Diablo.
With your code it's working like a charm.
Reply With Quote
  #33 (permalink)  
Old 03-15-2007, 06:57 PM
New Pligger
 
Join Date: Jul 2006
Posts: 11
still getting a blank related stories portion of my page.
Reply With Quote
  #34 (permalink)  
Old 03-15-2007, 10:04 PM
Banned
Pligg Version: 9.8.
Pligg Template: Custom
 
Join Date: Feb 2007
Location: Canada
Posts: 796
Blank for me as well. Anyone on the dev team able to come up with a solution?

Geoserv
Reply With Quote
  #35 (permalink)  
Old 03-15-2007, 10:12 PM
Banned
Pligg Version: 9.8.
Pligg Template: Custom
 
Join Date: Feb 2007
Location: Canada
Posts: 796
I think the issue is there is no GROUP BY clause for MySQL to read. There is one in the next set of queries, but you need one in the initial query.

Thats the error I get no matter what I do.

Geoserv.
Reply With Quote
  #36 (permalink)  
Old 03-15-2007, 10:13 PM
Pligg Developer/Admin
Pligg Version: 0
Pligg Template: none
 
Join Date: Jun 2006
Location: Muncie, Indiana
Posts: 3,215
It has worked fine for me so I'm not sure how I can solve something that isn't broken for me :/
Reply With Quote
  #37 (permalink)  
Old 03-17-2007, 04:05 PM
Casual Pligger
 
Join Date: Oct 2006
Posts: 89
Quote:
Originally Posted by diablo View Post
i used this
thanks, that worked for me

is there anyway that it can work so that it also searches the title
Reply With Quote
  #38 (permalink)  
Old 03-19-2007, 10:56 AM
Banned
Pligg Version: 9.8.
Pligg Template: Custom
 
Join Date: Feb 2007
Location: Canada
Posts: 796
Would it matter what version of MySQL was being used?

Geoserv
Reply With Quote
  #39 (permalink)  
Old 03-22-2007, 12:11 AM
New Pligger
 
Join Date: Mar 2007
Posts: 3
Does not work for me. http://doveup.com/ I have done as instructed and i am using the latest pligg. Need help please
Reply With Quote
  #40 (permalink)  
Old 03-23-2007, 03:53 PM
New Pligger
 
Join Date: Jan 2007
Posts: 5
How can you hide this if there are no matching tags?
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Related Stories from Digg, Twitter, YouTube alpapa23 Questions and Comments 0 08-04-2009 04:50 PM
Related Stories on Story Page canadianguy33 Questions and Comments 8 03-22-2008 03:39 PM
Related Stories Geoserv Questions and Comments 15 07-08-2007 12:21 PM
Related stories empty when tags separated by space aaronpais Questions and Comments 5 06-18-2007 11:32 PM
How can you make "Queued Stories" display promoted stories as well? gragland Questions and Comments 0 06-18-2006 01:24 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