News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Related Topics

Started by niko, September 14, 2005, 11:50:29 AM

Previous topic - Next topic

Prasad007

Quote from: Senkusha on April 21, 2006, 06:11:56 PM
Quote from: Prasad007 on April 21, 2006, 11:34:47 AM
Quote from: Senkusha on April 21, 2006, 05:20:03 AM
Quote from: Prasad007 on April 21, 2006, 03:28:48 AM
Quote from: Søren Bjerg on April 21, 2006, 03:27:18 AM
Quote from: Prasad007 on April 21, 2006, 03:19:02 AM
does this mod work on 1.1 rc2 ?
The version Senkusha posted in this post is an adapted version for 1.1 RC2.
okay ill try it.thanks!


*EDIT*
with that mod installed i get this error:

Quote
Database Error
Can't find FULLTEXT index matching the column list
File: /home/admin/public_html/forum/Sources/Display.php
Line: 174


You have to create a FULL TEXT index in your messages table.
how do u do that ?


Open your terminal / Command prompt, log into mysql and type the following command:

USE smf;
ALTER TABLE smf_messages ADD FULLTEXT(subject, body);


Based on what I read on the MYSQL site, this is how to modify a table to include a new index.
thanks. ill try that :)

kezayah

How to exclude the deleted topics in the list because I have a basket ...

I have tested :

$related = db_query("SELECT *, MATCH (ms.subject,ms.body) AGAINST ('{$mssub}') As Score  FROM {$db_prefix}messages As ms WHERE ((MATCH (ms.subject,ms.body)) AND (ms.ID_BOARD <> 'xx')) AGAINST ('{$mssub}') ORDER BY Score DESC LIMIT 0,10",__FILE__,__LINE__); //
'xx' = 75 for me

... but there is a error in MySQL  >:(

Thanks

kalligator

#82
@ Prasad007 don't forget:
Create FULLTEXT index: Go to (Admin->Forum->Search->Search Method), press "create a fulltext index"


Prasad007

Quote from: kalligator on May 04, 2006, 11:08:25 PM
@ Prasad007 don't forget:
Create FULLTEXT index: Go to (Admin->Forum->Search->Search Method), press "create a fulltext index"

yup thanks! :)

kezayah

Quote from: kezayah on May 04, 2006, 05:36:15 PM
How to exclude the deleted topics in the list because I have a basket ...

I have tested :

$related = db_query("SELECT *, MATCH (ms.subject,ms.body) AGAINST ('{$mssub}') As Score  FROM {$db_prefix}messages As ms WHERE ((MATCH (ms.subject,ms.body)) AND (ms.ID_BOARD <> 'xx')) AGAINST ('{$mssub}') ORDER BY Score DESC LIMIT 0,10",__FILE__,__LINE__); //
'xx' = 75 for me

... but there is a error in MySQL  >:(

Thanks
And for my problem ?  :-[

kezayah

Senkusha help me please !!!  :'(


ikbenivo

are you (the creator of this mod) going to update this mod? (you have a nice todo list...)

Linlay

Hi
I am getting some errors
Using the RC2 forum. Anybody can help ?

8: Undefined index: related_topics

raphaelu

Soryy for my english. I'm french.

This mod seems super but It's not ok on SMF 1.1 RC2

Somebody can help me to do it work ?

The related topic is something very good for user and i should be very happy to offer it to my members

Tanks before.
Raphael
hxxp:www.dogma.fr [nonactive]

Vinspire

Tried to install this but i've gotten this error.

QuoteInstalling this package will perform the following actions:
   Type    Action    Description
1.    Execute Modification    ./Sources/Display.php    Test successful
2.    Execute Modification    ./Themes/default/Display.template.php    Test failed

I am using SMF 1.1 RC 2

Thanks :)

kai920

I installed & created a full text search index, got this error:

QuoteCan't find FULLTEXT index matching the column list
File: /home/mydomain.com/forums/Sources/Display.php
Line: 173

Remaker

Quote from: kai920 on June 14, 2006, 10:09:29 PM
I installed & created a full text search index, got this error:

QuoteCan't find FULLTEXT index matching the column list
File: /home/mydomain.com/forums/Sources/Display.php
Line: 173

Open phpmyadmin and run this query:

ALTER TABLE smf_messages ADD FULLTEXT(subject, body);

That should do it.
Remaker - My blog

kai920

Thanks for the answer Remaker... I don't get the error message anymore - but there are no related topics that show below the message?

cookieoflife

Quote from: kai920 on July 01, 2006, 01:31:32 PM
Thanks for the answer Remaker... I don't get the error message anymore - but there are no related topics that show below the message?

I have the same error. Is there a way to rebuild the index, or something?

kezayah

This mod requires many queries !!!  :o :o :o
Is it possible to modfiy the code to reduce the number of queries ???

kezayah

I found it ...

Remplace the code in

--> display.php :

$terms = explode(" ",$topicinfo['subject']);

$mssub = '';
foreach($terms As $term)
{
$term = str_replace(array(":","-","+","~"),"",$term); // These are reversed in mysql need to remove to work correctly
if(strlen($term) > 3) $mssub .= trim($term)." ";
}

$mssub = trim(mysql_real_escape_string($mssub));
//fatal_error($mssub);

$related = db_query("
SELECT *, MATCH (ms.subject,ms.body)
AGAINST ('{$mssub}') As Score 
FROM {$db_prefix}messages As ms
WHERE MATCH (ms.subject,ms.body)
AGAINST ('{$mssub}')
ORDER BY Score DESC LIMIT 0,10",__FILE__,__LINE__); //

$context['related_topics'] = array();

$tids = array(
$topic => true,
);
while($relTopic = mysql_fetch_array($related)){
$x = $relTopic;
if(!isset($tids[$relTopic['ID_TOPIC']])){
$tids[$relTopic['ID_TOPIC']] = true;

$tox = db_query("
SELECT
m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER AS ID_MEMBER, ms.ID_MEMBER AS ID_FIRST_MEMBER, ms.posterTime AS firstPosterTime, m.ID_MSG, t.numReplies, t.numViews, t.ID_POLL, t.isSticky, t.locked, ms.icon,
IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(m.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(m.ID_MSG, -1)) + 1 AS new_from') . "
FROM ({$db_prefix}topics As t,{$db_prefix}messages As m,{$db_prefix}messages As ms)
LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)" : '') . "
WHERE t.ID_TOPIC='{$relTopic['ID_TOPIC']}'
AND m.ID_MSG = t.ID_LAST_MSG
AND ms.ID_MSG = t.ID_FIRST_MSG
LIMIT 0,1",__FILE__,__LINE__);

$x = mysql_fetch_array($tox);
mysql_free_result($tox);

// Decide how many pages the topic should have.
$topic_length = $x['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' . $scripturl . '?topic=' . $x['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = '&#171; ' . implode(' ', $tmppages);
// Or skip a few?
else
$pages = '&#171; ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $x['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
$pages .= ' &#187;';
}
else
$pages = '';

// Build the array.
$x = array(
'first_poster' => empty($x['ID_FIRST_MEMBER']) ? $x['firstPosterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $x['ID_FIRST_MEMBER'] . '">' . $x['firstPosterName'] . '</a>',
'poster' => empty($x['ID_MEMBER']) ? $x['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $x['ID_MEMBER'] . '">' . $x['posterName'] . '</a>',
'pages' => $pages,
'replies' => $x['numReplies'],
'views' => $x['numViews'],
'time' => timeformat($x['posterTime']),
'first_time' => timeformat($x['firstPosterTime']),
'href' => $scripturl . '?topic=' . $x['ID_TOPIC'] . '.msg' . $x['ID_MSG'] . ';topicseen#new',
'subject' => '<a href="' . $scripturl . '?topic=' . $x['ID_TOPIC'] . '">' . $x['subject'] . '</a>',
'is_sticky' => $x['isSticky'],
'is_locked' => $x['locked'],
'is_poll' =>  $x['ID_POLL'] > 0,
'new' => !empty($x['isRead']),
'new_from' => $x['new_from'],
'icon' => $settings['default_theme_url'] . '/images//post/' . $x['icon'] . '.gif',
);

if ($x['icon'] != 'recycled' && $x['icon'] != 'moved')
$context['related_topics'][] = $x;
}
}
mysql_free_result($related);

kezayah

In display.template.php, replace :

$showRelated = false;
if(is_array($context['related_topics']) && count($context['related_topics']) > 0)
$showRelated = true;

if($showRelated)
{
$dhtml_collapsed = get_collapsed_state("related_topics");
echo '
<table><tr><td style="padding: 0 0 1px 0;"></td></tr></table>
<table border="0" width="100%" cellspacing="1" cellpadding="3" class="bordercolor">
<tbody>
<tr class="catbg">
<td align="center" colspan="6">
<a style="float:right;" href="javascript:void(0);" onclick="doCollapseObject(\'related_topics\', \'', $settings['csect_cookie'], '\'); return false;"><img class="midimage" id="img_related_topics" src="', $settings['images_url'], $dhtml_collapsed ? '/expand_b.gif' : '/collapse_b.gif', '" alt="*" border="0" /></a>', 'Topics similaires', '</td>
</tr>
</tbody>
<tbody id="related_topics"', $dhtml_collapsed ? ' style="display:none;" ' : ' ', '>
<tr class="titlebg">
<td colspan="2" align="center">', $txt[70], '</td>
<td width="18%">' . $txt[109] . '</td>
<td width="4%" align="center">', $txt[110], '</td>
<td width="4%" align="center">', $txt[301], '</td>
<td width="18%">', $txt[111], '</td>
</tr>';

$i = 0;

foreach($context['related_topics'] as $tmp)
{
echo '
<tr class="', $i ? 'windowbg' : 'windowbg2' , '">
<td valign="middle" align="center" width="3%"><img src="' . $tmp['icon'] . '" alt="" />&nbsp;</td>
<td valign="middle">';

if($tmp['is_sticky'])
echo '<span style="float:right"><img src="', $settings['images_url'], '/topic/sticky_topic.gif" alt="', $txt['smf96'], '" title="', $txt['smf96'], '" border="0" /></span>';

if($tmp['is_locked'])
echo '<span style="float:right"><img src="', $settings['images_url'], '/topic/locked_topic.gif" alt="', $txt['igoh_locked'], '" title="', $txt['igoh_locked'], '" border="0" /></span>';

if($tmp['is_poll'])
echo '<span style="float:right"><img src="', $settings['images_url'], '/topic/poll_topic.gif" alt="', 'Sondage', '" title="', 'Sondage', '" border="0" /></span>';

echo '' . $tmp['subject'] . '
', $tmp['new'] ? '' : '<a href="' . $tmp['href'] . '"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', '';
if (!empty($tmp['pages']))
echo '
<br /><span style="padding: 4px 0 2px 0;" class="small_pagelink"><img style="margin: 0 0 -3px 0; padding: 0 2px 0 0;" src="', $settings['images_url'], '/topic/multi_pg.gif" width="11" alt="', $txt['multi_pg'], '" title="', $txt['multi_pg'], '" border="0" />', $tmp['pages'], '</span>';
echo '
</td>
<td valign="middle" width="18%">
<span class="smalltext">
' . $tmp['first_time'] . '<br />
' . $txt[525] . ' ' . $tmp['first_poster'] . '
</span>
</td>
<td valign="middle" align="center" width="4%">' . $tmp['replies'] . '</td>
<td valign="middle" align="center" width="4%">' . $tmp['views'] . '</td>
<td valign="middle" width="18%">
<span class="smalltext">
' . $tmp['time'] . '<br />
<a href="' . $tmp['href'] . '"><img src="' . $settings['images_url'] . '/icons/last_post.gif" alt="' . $txt[111] . '" title="' . $txt[111] . '" border="0" style="float: right;" /></a>
' . $txt[525] . ' ' . $tmp['poster'] . '
<span>
</td>
</tr>';
$i=1-$i;
}
echo '</tbody></table>';
}

Aaron Nelsen

I can't get any releated topics to show up. I manually installed the mod since the Package Manager won't do it.

I've created a full text index, I've even switched back to the default template for 1.1 RC2.

I'm getting a lot of these messages in my error logs:

Undefined variable: showRelated
Undefined variable: mssub

Any suggestions?

fiver

#99
Hi kezayah,

Using your suggested codes with 1.1rc2, I got this error at the bottom of the topic page:
Fatal error: Call to undefined function: get_collapsed_state() in /home/fivearts/public_html/Sources/Load.php(1613) : eval()'d code on line 640

Any solution is greatly appreciated. Thanks

:D


Advertisement: