New Mod -- Display related stories

Register an Account
Reply
 
Thread Tools Display Modes
  #41 (permalink)  
Old 03-24-2007, 12:38 AM
Banned
Pligg Version: 9.8.
Pligg Template: Custom
 
Join Date: Feb 2007
Location: Canada
Posts: 796
No one has any insight for those of us who can't get this to work?

Geoserv
Reply With Quote
  #42 (permalink)  
Old 06-07-2007, 03:10 AM
Constant Pligger
 
Join Date: Jun 2006
Posts: 108
Can This mod be adapted so related stories will be based on the Category? this would be awesome.

Does anyone also have code to display a pre-defined number of stories per category on the front page, like your typical newspaper...

THanks

noyP

Noyp
Reply With Quote
  #43 (permalink)  
Old 06-12-2007, 12:45 PM
New Pligger
 
Join Date: Dec 2006
Location: Finland
Posts: 1
Related stories wasn't working for me. The main problem was with this line:
Code:
$related_tags="'".str_replace(", ","', '",addslashes($related_tags))."'"; // This gives us the proper string structure for IN SQL statement
which has one space too many, so it didn't give the proper string structure. Here is corrected version:
Code:
$related_tags="'".str_replace(",","', '",addslashes($related_tags))."'"; // This gives us the proper string structure for IN SQL statement
I also used diablos code and made few modifications. Here is my related_stories function. It's working fine for me.

Code:
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(",","', '",addslashes($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 != 'discard'  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";
    $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;    
}
Maybe this helps someone...
Reply With Quote
  #44 (permalink)  
Old 06-12-2007, 01:08 PM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,042
I´m a little bit confused. Is this mod the same as the standard function of v9.5 (Only Search 'Title' and 'Tags'
Reply With Quote
  #45 (permalink)  
Old 06-15-2007, 10:25 PM
Casual Pligger
 
Join Date: Aug 2006
Posts: 41
Quote:
Originally Posted by timusa View Post
Hi

Please read the license, specially 2. d), which is part of Pligg's software.

You're are making something illegal when you removed the copyright notice on the site and the link to the license and code download address.

Don't take this personally. I believe that you did it with no harm but you were careless and didn't read the license before using it.

This is Free Software and not Public Domain.

Best,
Lopo
Reply With Quote
  #46 (permalink)  
Old 06-15-2007, 11:08 PM
P1mpPanther's Avatar
Constant Pligger
 
Join Date: Feb 2007
Posts: 277
I can't believe I just found this thread :-P

So I used diablos code and everything is working a-ok.

Another 'bug' that is inherent in Pligg shows up here - discarded stories with the same title as a non-discarded story shows up. I went into the database and deleted the dupe entries and everything is cool now.
Reply With Quote
  #47 (permalink)  
Old 07-07-2007, 02:19 AM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,042
Quote:
Originally Posted by tbones View Post
I´m a little bit confused. Is this mod the same as the standard function of v9.5 (Only Search 'Title' and 'Tags'
Would anybody be so kind to answer me that question? And I want to be more precise: Is this version of the code the one used in v9.5?
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