Welcome, Guest
Username Password: Remember me
Joomla!Day USA West | October 1-3, 2010

relative posts hack 0.1 beta
(1 viewing) (1) Guest

TOPIC: relative posts hack 0.1 beta

relative posts hack 0.1 beta 1 year ago #1

open view.php and find this:
<!-- F: List Actions Bottom -->


and paste this after:
<?php
//similar posts hack by guerilla
 
$percent=5; //similarity percentage, increase for sensitive matching. for example 10 is 10% match, 50 is 50% match, 100 is one o one
$topics_only=0; //set 1 if you wanna show only topics, set 0 to show relative messages directly
$limit = 5; //set number of relative messages
 
if ($topics_only = 1)
{
$parent =" AND parent=0 ";
}
 
$query=("SELECT id, subject, name, time as zaman, catid, userid, MATCH(t1.message) AGAINST('$this_message->subject') as oran1, MATCH(t2.subject) AGAINST('$this_message->subject') as oran2 FROM
#__fb_messages_text as t1 INNER JOIN #__fb_messages as t2 ON t2.id = t1.mesid
WHERE (MATCH(t1.message) AGAINST('$this_message->subject') > $percent OR MATCH(t2.subject) AGAINST('$this_message->subject') > $percent) AND t2.id <>"
. $this_message->id . $parent . " ORDER BY oran2 DESC, oran1 DESC LIMIT $limit;");
 
 
$sim_message=$kunena_db->setQuery($query);
$sim_message = $kunena_db->loadObjectList();
echo mysql_error();
if (count($sim_message)> 0)
{
echo '<table class = "fb_blocktable' . $objCatInfo->class_sfx . '" id="fb_views" border = "0" cellspacing = "0" cellpadding = "5" width="100%"><thead><tr><th colspan="4"><div class = "fb_title_cover fbm">';
echo '<span class = "fb_title fbl"><b>Relative Posts</b></span></div></th></tr></thead>';
echo '<tr class = "fb_sth"><td class = "view-th ' . $boardclass . 'sectiontableheader"><b>Subject</b></td><td><b>Author</b></td><td align="right"><b>Date</b></td><td align="right"><b>Similarity</b></td></tr>';
 
foreach ($sim_message as $sonuc) {
if ($sonuc->oran1 > $sonuc->oran2)
{
$oran = $sonuc->oran1;
}
else {
$oran=$sonuc->oran2;
}
echo "<tr><td><a href=\"index.php?option=com_kunena&Itemid=" . KUNENA_COMPONENT_ITEMID . "&func=view&catid=" . $sonuc->catid . "&id=" . $sonuc->id. "\">" . $sonuc->subject . "</a></td>";
echo "<td>" . CKunenaLink::GetProfileLink($fbConfig, $sonuc->userid, $sonuc->name) . "</td>";
echo "<td align=\"right\">" . date(_DATETIME, $sonuc->zaman) . "</td>";
echo "<td align=\"right\">%" . (int)$oran . "</td></tr>";
}
echo "</table>";
}
//similar posts hack by gerilla
?>


finally open your phpmysqladmin and run this scripts:

 
ALTER TABLE jos_fb_messages ADD FULLTEXT(subject)
 
ALTER TABLE jos_fb_messages_text ADD FULLTEXT(message)



thats all.

acknowledgements:
-to increase sensitivity of matching increase $percent=5; (for example $percent=10 ) value can between 0 to 100.

-$topics_only=0; //set this 1 if you wanna show only topics, set 0 to show all relatve posts directly (default is 0)
-$limit sets maximum number of relative posts showing, default is 5. you can set this what you want. 3, 8, 10 or 20 etc...

NOTE: DO NOT COPY CODES DIRECTLY FROM POST. PRESS QUOTE AND THEN COPY THE CODES FROM TEXT AREA.
  • guerilla
  • OFFLINE
  • Senior Boarder
  • Posts: 136
Last Edit: 1 year ago By guerilla.

Re:relative posts hack 0.1 beta 1 year ago #2

good job, but i have a problem.

Parse error: parse error in C:\xampplite\htdocs\caco\components\com_kunena\template\default_ex\view.php on line 1238

Re:relative posts hack 0.1 beta 1 year ago #3

did you copy post directly? kunena adds unwanted spaces to code. press quote button and copy the code from textarea.

by the way i forgot to tell, you must add fultext to search fields. open your phpmysqladmin and run this scripts:

ALTER TABLE jos_fb_messages ADD FULLTEXT(subject)

ALTER TABLE jos_fb_messages_text ADD FULLTEXT(message)
  • guerilla
  • OFFLINE
  • Senior Boarder
  • Posts: 136

Re:relative posts hack 0.1 beta 1 year ago #4

thanks great hack..
can see , this work.

Re:relative posts hack 0.1 beta 10 months, 3 weeks ago #5

Sorry, but it doesn't work for me!
Please, help
When I enter any post (not topic) I see this - see the attachment

I have done everything correctly. I have made "tag hack" without any problems, so I know how to do that.
And I swithed on mistakes - nothing. I thought, I would see some syntax error at least. But nothing at all, so I do not really know where to look for that trouble to correct.
Attachments:
  • FENIX
  • OFFLINE
  • Fresh Boarder
  • Posts: 19
Last Edit: 10 months, 3 weeks ago By FENIX.

Re:relative posts hack 0.1 beta 10 months, 3 weeks ago #6

did you copy code from post directly? you must first click quote and copy the code from text area.
  • guerilla
  • OFFLINE
  • Senior Boarder
  • Posts: 136

Re:relative posts hack 0.1 beta 10 months, 3 weeks ago #7

Well, a little bit better but still ...
See the picture, please
Attachments:
  • FENIX
  • OFFLINE
  • Fresh Boarder
  • Posts: 19

Re:relative posts hack 0.1 beta 10 months, 3 weeks ago #8

could you send me your view.php file?
  • guerilla
  • OFFLINE
  • Senior Boarder
  • Posts: 136

Re:relative posts hack 0.1 beta 10 months, 3 weeks ago #9

Yes, of course. Here you are.
Thank you in advance

File Attachment:

File Name: view2.zip
File Size: 13799
Attachments:
  • FENIX
  • OFFLINE
  • Fresh Boarder
  • Posts: 19
Last Edit: 10 months, 3 weeks ago By FENIX.

Re:relative posts hack 0.1 beta 10 months, 3 weeks ago #10

i removed related posts hack code and it still same. so, i guess you've changed something accidently, maybe a code or php signal, i dont know.

i offer try adding this hack to a new view.php file, so if it works move your other mods one by one to it.

good luck...
  • guerilla
  • OFFLINE
  • Senior Boarder
  • Posts: 136
Last Edit: 10 months, 3 weeks ago By guerilla.
Time to create page: 1.13 seconds