Related stories empty when tags separated by space

Register an Account
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 06-18-2007, 05:42 PM
Constant Pligger
 
Join Date: Apr 2007
Posts: 168
In my implementation of Pligg (v9.5), my tags are separated by a space (not by a comma). So, the related stories tab is empty.

Can someone advise as to what needs to be changed in the code to make it work?

I suspect the function added to the html1.php file needs to be changed. Here it is:

---
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))."'"; //

// 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;
}

---

Thx
-A
Reply With Quote
  #2 (permalink)  
Old 06-18-2007, 05:52 PM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,042
This is a general problem: Related Stories
Reply With Quote
  #3 (permalink)  
Old 06-18-2007, 06:58 PM
Constant Pligger
 
Join Date: Apr 2007
Posts: 168
I took a stab at the first part of the query.

Replace

PHP Code:
$related_tags="'".str_replace(",","', '",addslashes($related_tags))."'"// 
with

PHP Code:
$related_tags="'".str_replace(" ","', '",addslashes($related_tags))."'"// 
This should convert the spaces in the tags into comma separated tags. The related stories tab is still blank for me. Any SQL experts here?

I am on Pligg v9.5

Thx
-A
Reply With Quote
  #4 (permalink)  
Old 06-18-2007, 11:17 PM
Constant Pligger
 
Join Date: Apr 2007
Posts: 168
Ash, need your help. I just realized that I have to add commas between my tags based on the design of Pligg.

My tags is a copy of my title

In submit_step_3.tpl, I changed line 59

PHP Code:
$linkres->tags tags_normalize_string(strip_tags(trim($_POST['title']))); 
so my tags is a copy of my title. I now need to replace the space in the tags with a comma. Would the following tweak work, Ash?

PHP Code:
$linkres->tags tags_normalize_string(strip_tags(trim($_POST['str_replace(" ", ", ", $linkres->tags);']))); 
Thx
-A
Reply With Quote
  #5 (permalink)  
Old 06-18-2007, 11:25 PM
AshDigg's Avatar
Mayor of PliggVille/Coder
 
Join Date: Dec 2005
Posts: 1,515
I don't know if it will work, but there is a problem with the code

PHP Code:
trim($_POST['str_replace(" ", ", ", $linkres->tags);']) 
should be

PHP Code:
trim(str_replace(" "", "$linkres->tags)) 
you don't need the $_POST or the extra ;
Reply With Quote
  #6 (permalink)  
Old 06-18-2007, 11:32 PM
Constant Pligger
 
Join Date: Apr 2007
Posts: 168
Thx. It is resolved....

Last edited by aaronpais; 06-18-2007 at 11:49 PM.
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
New Mod -- Display related stories revenazb Questions and Comments 46 07-07-2007 02:19 AM
[Mod Request] Tags separeted by space elro Questions and Comments 5 06-15-2007 05:28 PM


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