New Mod -- Display related stories

Register an Account
Reply
 
Thread Tools Display Modes
  #11 (permalink)  
Old 03-13-2007, 11:17 PM
New Pligger
 
Join Date: Mar 2007
Posts: 9
Quote:
Originally Posted by Geoserv View Post
I am having an issue with this mod, its a great feature, but it doesn't seem to work. Also, it appears at the bottom of the screen.

http://www.newsdots.com/story.php?title=CSS-Superdouche

Geoserv
I think the reason it doesn't work is because you posts that share tags are in different categories, for my purpose I made so it would only look for posts in the same category.
You can easily change that by commenting the following line in the code I posted:
PHP Code:
//comment the following line out if you want this to work accross categories
    
$sql.= " AND ".table_links.".link_category = ".$category
As for why it shows up at the bottom, that is css issue with the template you are using and where you put the:
Code:
{include file=$the_template."/story_related_stories.tpl"}
Look in your story_center.tpl template for the decalration that lists users who voted and put the line right underneath instead of at the bottom of the file.

Hope this helps
Reply With Quote
  #12 (permalink)  
Old 03-13-2007, 11:30 PM
Banned
Pligg Version: 9.8.
Pligg Template: Custom
 
Join Date: Feb 2007
Location: Canada
Posts: 796
I still see no related stories.

Geoserv.
Reply With Quote
  #13 (permalink)  
Old 03-13-2007, 11:34 PM
Banned
Pligg Version: 9.8.
Pligg Template: Custom
 
Join Date: Feb 2007
Location: Canada
Posts: 796
Heres what I have:

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 != 'discard' AND NOT ".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;
}
Reply With Quote
  #14 (permalink)  
Old 03-13-2007, 11:56 PM
Banned
Pligg Version: 9.8.
Pligg Template: Custom
 
Join Date: Feb 2007
Location: Canada
Posts: 796
kbeeveer can you post the code you used? Or, what about the above is preventing this from working?

Geoserv
Reply With Quote
  #15 (permalink)  
Old 03-13-2007, 11:57 PM
Pligg Developer/Admin
Pligg Version: 0
Pligg Template: none
 
Join Date: Jun 2006
Location: Muncie, Indiana
Posts: 3,215
The code I used is the same code on the forum besides the link_status != 'discard'. The problem I had was that I was testing it will unpublished stories and the code that is on the forum only worked with published stories.
Reply With Quote
  #16 (permalink)  
Old 03-14-2007, 12:02 AM
Banned
Pligg Version: 9.8.
Pligg Template: Custom
 
Join Date: Feb 2007
Location: Canada
Posts: 796
hmm...this is a great mod, but I wish I could get it to work.

Geoserv.
Reply With Quote
  #17 (permalink)  
Old 03-14-2007, 12:17 AM
New Pligger
 
Join Date: Mar 2007
Posts: 9
geoserv,

Add the following line after the $sql = .......
echo $sql;

That will print out the sql in the top of your site (if it is hidden look in the source). Copy/paste this sql into phpmyadmin (or whatever you use to run queries on the database directly) and see if you get stories being returned. If you do then the problem is in the templating

Bert
Reply With Quote
  #18 (permalink)  
Old 03-14-2007, 06:31 AM
Constant Pligger
 
Join Date: Feb 2007
Posts: 226
This feature seems nice and useful.
I have the same problem as Geoser. Only the Related stories header is showing up in the story-page.

I have copy-pasted the code by following the instructions a few times now but still not working.
Also tried the echo $sql; and copy-pasted the query in PHPmyadmin but it gave me 0 rows from my Pligg's database.

This is the query that the echo $sql; gave me. Is there something wrong?
Code:
SELECT pligg_links.link_title, pligg_links.link_title_url, COUNT( pligg_tags.tag_link_id ) AS relevance, pligg_tags.tag_link_id FROM pligg_tags, pligg_links
WHERE pligg_tags.tag_words IN ( 'web', 'internet', 'music', 'video' ) AND pligg_tags.tag_link_id = pligg_links.link_id AND pligg_links.link_status =
'published' AND NOT pligg_links.link_id = 568 AND pligg_links.link_category = 4 GROUP BY pligg_tags.tag_link_id, pligg_links.link_title, pligg_links.link_title_url
ORDER BY relevance DESC LIMIT 10
There is stories tagged with same tags in the same category.
I'm not very good with PHPmyadmin or Mysql so I can't see is there something wrong in that query. I'm using Pligg 9.1 with Mollio-beat.
Reply With Quote
  #19 (permalink)  
Old 03-14-2007, 06:33 AM
Casual Pligger
 
Join Date: Oct 2006
Posts: 33
This mod looks great!

I am about halfway through doing something similar, but much narrower, as a module. I'm sure your code will be very useful to me :>
Reply With Quote
  #20 (permalink)  
Old 03-14-2007, 07:43 AM
Banned
Pligg Version: 9.8.
Pligg Template: Custom
 
Join Date: Feb 2007
Location: Canada
Posts: 796
All I get are errors when I run the query on PHPmyadmin, heres the query I pasted:

Quote:
" 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;
echo $sql;
Geoserv
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