ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ThaiSEOBoard.comพัฒนาเว็บไซต์CMS & Free Scriptการทำ กระทู้ที่เกี่ยวข้อง [SMF]
หน้า: [1]   ลงล่าง
พิมพ์
ผู้เขียน หัวข้อ: การทำ กระทู้ที่เกี่ยวข้อง [SMF]  (อ่าน 1830 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
Putter™
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 421
ออฟไลน์ ออฟไลน์

กระทู้: 2,104



ดูรายละเอียด เว็บไซต์
« เมื่อ: 18 มกราคม 2010, 05:10:38 »

ถ้างงมันคืออะไร ก็ ตามรูปเลยครับ


ถ้ายัง งงๆ ก็ Click ที่รูป แล้วดูด้านล่างสุดเลยครับ



เพื่อไม่ให้เป็นการเสียเวลามาเริ่มกันเลยดีกว่าครับ

เปิดไฟล์ source/ModSettings.php

ค้นหา
โค๊ด:
	'',
// Reactive on email, and approve on delete

เอาไว้ก่อนหน้าที่หา
โค๊ด:
'',
// Related Topics
array('check', 'relatedTopicsEnabled'),
array('int', 'relatedTopicsCount'),
array('select', 'relatedIndex', array('fulltext' => $txt['relatedFulltext'])),

เปิดไฟล์ source/RemoveTopic.php

ค้นหา
โค๊ด:
	else
$condition = 'IN (' . implode(', ', $topics) . ')';

ขึ้นบรรทัดใหม่
โค๊ด:
// Added by Related Topics
require_once($sourcedir . '/Subs-Related.php');
removeRelated($topics);
// Related Topics END

เปิดไฟล์  source/Subs-Post.php

ค้นหา
โค๊ด:
$topicOptions['id'] = db_insert_id();

ขึ้นบรรทัดใหม่
โค๊ด:
// Added by Related Topics
global $sourcedir;
require_once($sourcedir . '/Subs-Related.php');
addRelated($topicOptions['id'], $msgOptions['subject']);
// Related Topics END

ค้นหา
โค๊ด:
updateStats('subject', $topicOptions['id'], $msgOptions['subject']);
mysql_free_result($request);


ขึ้นบรรทัดใหม่
โค๊ด:
// Added by Related Topics
global $sourcedir;
require_once($sourcedir . '/Subs-Related.php');
addRelated($topicOptions['id'], $msgOptions['subject']);
// Related Topics END

เปิดไฟล์ source/Display.php

ค้นหา
โค๊ด:
$topicinfo = mysql_fetch_assoc($request);
mysql_free_result($request);

ขึ้นบรรทัดใหม่
โค๊ด:
// Added by Related Topics
if (!empty($modSettings['relatedTopicsEnabled']))
{
require_once($sourcedir . '/Subs-Related.php');
$context['related_topics'] = loadRelated($topic);
}

เปิดไฟล์ theme/Display.template.php

ค้นหาประมาณนี้
โค๊ด:
	echo '
<input type="hidden" name="sc" value="' . $context['session_id'] . '" />
<input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '" />
</form>
</td>
</tr>
</table>';
}

ขึ้นบรรทัดใหม่
โค๊ด:
// Added by Related Topics
if (!empty($context['related_topics']) > 0)
{
echo '
<br />
<div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;"' : '', '>
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
<tr class="titlebg">
<td colspan="7">', $txt['related_topics'], '</td>
</tr>
<tr>
<td width="9%" colspan="2" class="catbg3"></td>
<td class="catbg3">', $txt[70],'</td>
<td class="catbg3">', $txt[109],'</td>
<td class="catbg3">', $txt[110],'</td>
<td class="catbg3">', $txt[301],'</td>
<td class="catbg3">', $txt[111],'</td>
</tr>';

foreach ($context['related_topics'] as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="5%">
<img src="', $settings['images_url'], '/topic/', $topic['class'], '.gif" alt="" />
</td>
<td class="windowbg2" valign="middle" align="center" width="4%">
<img src="', $topic['first_post']['icon_url'], '" alt="" />
</td>
<td class="windowbg' , !empty($settings['seperate_sticky_lock']) && $topic['is_sticky'] ? '3' : '' , '" valign="middle" ', (!empty($topic['quick_mod']['remove']) ? 'id="topic_' . $topic['first_post']['id'] . '" onmouseout="mouse_on_div = 0;" onmouseover="mouse_on_div = 1;" ondblclick="modify_topic(\'' . $topic['id'] . '\', \'' . $topic['first_post']['id'] . '\', \'' . $context['session_id'] . '\');"' : ''), '>';

if (!empty($settings['seperate_sticky_lock']))
echo '
' , $topic['is_locked'] ? '<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" id="lockicon' . $topic['first_post']['id'] . '" style="margin: 0;" />' : '' , '
' , $topic['is_sticky'] ? '<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" id="stickyicon' . $topic['first_post']['id'] . '" style="margin: 0;" />' : '';

echo '
', $topic['is_sticky'] ? '<b>' : '' , '<span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], '</span>', $topic['is_sticky'] ? '</b>' : '';

// Is this topic new? (assuming they are logged in!)
if ($topic['new'] && $context['user']['is_logged'])
echo '
<a href="', $topic['new_href'], '" id="newicon' . $topic['first_post']['id'] . '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';

echo '
<small id="pages' . $topic['first_post']['id'] . '">', $topic['pages'], '</small><br />
<small>', $topic['board_link'], '</small>
</td>
<td class="windowbg2" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '
</td>
<td class="windowbg' , $topic['is_sticky'] ? '3' : '' , '" valign="middle" width="4%" align="center">
', $topic['replies'], '
</td>
<td class="windowbg' , $topic['is_sticky'] ? '3' : '' , '" valign="middle" width="4%" align="center">
', $topic['views'], '
</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span>
</td>';

echo '
</tr>';

}

echo '
</table>
</div>';
}

เปิดไฟล์ index.php (หน้าแรก board/index.php)

ค้นหา
โค๊ด:
'register2' => array('Register.php', 'Register2'),

ขึ้นบรรทัดใหม่
โค๊ด:
'related' => array('Subs-Related.php', 'Related'),


เปิดไฟล์ language/Modifications.english.php และก็ Modifications.thai-utf8.php

เพิ่มไว้ก่อน ?>

โค๊ด:
// Added by Related Topics
$txt['admin_related_topic'] = 'กระทู้ที่เกี่ยวข้อง';
$txt['related_topics'] = 'กระทู้ที่เกี่ยวข้อง';
$txt['relatedTopicsEnabled'] = 'Enable Related Topics';
$txt['relatedTopicsCount'] = 'How many related topics to show';
$txt['relatedIndex'] = 'Indexing method<div class="smalltext"><b><a href="' . $scripturl . '?action=related;sa=index;begin">Build index</a></b></div>';
$txt['relatedFulltext'] = 'Fulltext';
$txt['relatedCustom'] = 'Custom';


เสร็จขั้นตอนการแก้ไขไฟล์



ต่อไปสร้างไฟล์ ไปไว้ใน Source/ นะครับ

ไฟล์แรกตั้งชื่อว่า Subs-Related.php
โค๊ด:
<?php
/**********************************************************************************
* Subs-Related.php                                                                *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under   *
* the terms of the provided license as published by Simple Machines LLC.          *
*                                                                                 *
* This program is distributed in the hope that it is and will be useful, but      *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY    *
* or FITNESS FOR A PARTICULAR PURPOSE.                                            *
*                                                                                 *
* See the "license.txt" file for details of the Simple Machines license.          *
* The latest version can always be found at http://www.simplemachines.org.        *
**********************************************************************************/

function Related()
{
global $scripturl$txt$db_prefix$modSettings$context;
global $user_info$func;

isAllowedTo(&#39;admin_forum&#39;);

if (isset($_REQUEST[&#39;sa&#39;]) && $_REQUEST[&#39;sa&#39;] == &#39;index&#39;)
{
buildTopicIndex();
}
}

// Build index
function buildTopicIndex()
{
global $scripturl$txt$db_prefix$modSettings$context$sourcedir;

loadTemplate(&#39;Admin&#39;);
loadLanguage(&#39;Admin&#39;);

if (!isset($context[&#39;relatedClass&#39;]))
initRelated();

$context[&#39;start&#39;] = empty($_REQUEST[&#39;start&#39;]) ? 0 : (int) $_REQUEST[&#39;start&#39;];

if (isset($_REQUEST[&#39;begin&#39;]) || (!isset($_REQUEST[&#39;rel&#39;]) && $_REQUEST[&#39;start&#39;] == 0))
{
$context[&#39;relatedClass&#39;]->recreateIndexTables();

db_query("DELETE FROM {$db_prefix}related_topics"__FILE____LINE__);
}

$request db_query("
SELECT MAX(ID_TOPIC)
FROM 
{$db_prefix}topics"__FILE____LINE__);
list ($max_topics) = mysql_fetch_row($request);
mysql_free_result($request);

$last $_REQUEST[&#39;start&#39;] + 200;

$context[&#39;sub_template&#39;] = &#39;not_done&#39;;
$context[&#39;continue_get_data&#39;] = &#39;?action=related;sa=index&#39; . (isset($_REQUEST[&#39;rel&#39;]) ? &#39;;rel&#39; : &#39;&#39;) . &#39;;start=&#39; . $last;

$context[&#39;continue_percent&#39;] = round(100 * $_REQUEST[&#39;start&#39;] / $max_topics);
$context[&#39;continue_post_data&#39;] = &#39;&#39;;

$request db_query("
SELECT t.ID_TOPIC, mf.subject
FROM 
{$db_prefix}topics AS t
INNER JOIN 
{$db_prefix}messages AS mf ON (mf.ID_MSG = t.ID_FIRST_MSG)
WHERE t.ID_TOPIC > 
$context[start]
AND t.ID_TOPIC <= 
$last"__FILE____LINE__);

$topics = array();

while ($row mysql_fetch_assoc($request))
{
if (!isset($_REQUEST[&#39;rel&#39;]))
$topics[] = array($row[&#39;ID_TOPIC&#39;], $row[&#39;subject&#39;]);
else
createRelations($row[&#39;ID_TOPIC&#39;], $row[&#39;subject&#39;]);
}
mysql_free_result($request);

if (!isset($_REQUEST[&#39;rel&#39;]))
addRelated($topics, &#39;&#39;, true);

if ($last >= $max_topics)
{
if (!isset($_REQUEST[&#39;rel&#39;]))
$context[&#39;continue_get_data&#39;] = &#39;?action=related;sa=index;rel&#39;;
else
$context[&#39;continue_get_data&#39;] = &#39;?action=admin;area=modsettings;sa=related&#39;;
}

$context[&#39;continue_countdown&#39;] = 5;
}

// Main funtions
function loadRelated($topic)
{
global $modSettings$context$db_prefix$user_info;

$result db_query("
SELECT IF(rt.id_topic_first = 
$topic, rt.id_topic_second, rt.id_topic_first) AS ID_TOPIC
FROM 
{$db_prefix}related_topics AS rt
JOIN 
{$db_prefix}topics AS t ON (t.ID_TOPIC = IF(rt.id_topic_first = $topic, rt.id_topic_second, rt.id_topic_first))
JOIN 
{$db_prefix}boards AS b ON (b.ID_BOARD = t.ID_BOARD)
WHERE (id_topic_first = 
$topic OR id_topic_second = $topic)
AND 
$user_info[query_see_board]
ORDER BY rt.score DESC
LIMIT 
$modSettings[relatedTopicsCount]"__FILE____LINE__);

if (mysql_num_rows($result) == 0)
return false;

$topics_ids = array();
while ($row mysql_fetch_assoc($result))
$topics_ids[] = $row[&#39;ID_TOPIC&#39;];

mysql_free_result($result);

return prepareTopicArray($topics_ids);
}

function 
prepareTopicArray($topics_ids)
{
global $scripturl$txt$db_prefix$modSettings$context$settings;
global $options$sourcedir$user_info$ID_MEMBER$board_info$func;

// Setup the default topic icons...
$stable_icons = array(&#39;xx&#39;, &#39;thumbup&#39;, &#39;thumbdown&#39;, &#39;exclamation&#39;, &#39;question&#39;, &#39;lamp&#39;, &#39;smiley&#39;, &#39;angry&#39;, &#39;cheesy&#39;, &#39;grin&#39;, &#39;sad&#39;, &#39;wink&#39;, &#39;moved&#39;, &#39;recycled&#39;, &#39;wireless&#39;);
$context[&#39;icon_sources&#39;] = array();
foreach ($stable_icons as $icon)
$context[&#39;icon_sources&#39;][$icon] = &#39;images_url&#39;;

if (empty($topics_ids))
return false;

$topics_ids implode(&#39;,&#39;, $topics_ids);

$result db_query("
SELECT
t.ID_TOPIC, t.numReplies, t.locked, t.numViews, t.isSticky, t.ID_POLL,
. ($user_info[&#39;is_guest&#39;] ? &#39;0&#39; : &#39;IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1&#39;) . " AS new_from,
t.ID_LAST_MSGml.posterTime AS lastPosterTimeml.ID_MSG_MODIFIED,
ml.subject AS lastSubjectml.icon AS lastIconml.posterName AS lastMemberName,
ml.ID_MEMBER AS lastID_MEMBERIFNULL(meml.realNameml.posterName) AS lastDisplayName,
t.ID_FIRST_MSGmf.posterTime AS firstPosterTime,
mf.subject AS firstSubjectmf.icon AS firstIconmf.posterName AS firstMemberName,
mf.ID_MEMBER AS firstID_MEMBERIFNULL(memf.realNamemf.posterName) AS firstDisplayName,
LEFT(ml.body384) AS lastBodyLEFT(mf.body384) AS firstBodyml.smileysEnabled AS lastSmileys,
mf.smileysEnabled AS firstSmileysb.ID_BOARDb.name
FROM {$db_prefix}topics AS t
JOIN {$db_prefix}boards AS b ON (b.ID_BOARD t.ID_BOARD)
JOIN {$db_prefix}messages AS ml ON (ml.ID_MSG t.ID_LAST_MSG)
JOIN {$db_prefix}messages AS mf ON (mf.ID_MSG t.ID_FIRST_MSG)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER ml.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS memf ON (memf.ID_MEMBER mf.ID_MEMBER)" . ($user_info[&#39;is_guest&#39;] ? &#39;&#39; : "
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC t.ID_TOPIC AND lt.ID_MEMBER $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD b.ID_BOARD AND lmr.ID_MEMBER $ID_MEMBER)") . "
WHERE $user_info[query_see_board]
AND t.ID_TOPIC IN ($topics_ids)
LIMIT $modSettings[relatedTopicsCount]", __FILE__, __LINE__);

$return = array();

while (
$row = mysql_fetch_assoc($result))
{
if (
$row[&#39;ID_POLL&#39;] > 0 && $modSettings[&#39;pollMode&#39;] == &#39;0&#39;)
continue;

// Limit them to 128 characters - do this FIRST because it&#39;s a lot of wasted censoring otherwise.
$row[&#39;firstBody&#39;] = strip_tags(strtr(parse_bbc($row[&#39;firstBody&#39;], $row[&#39;firstSmileys&#39;], $row[&#39;ID_FIRST_MSG&#39;]), array(&#39;<br />&#39; => &#39;&#39;)));
if (
$func[&#39;strlen&#39;]($row[&#39;firstBody&#39;]) > 128)
$row[&#39;firstBody&#39;] = $func[&#39;substr&#39;]($row[&#39;firstBody&#39;], 0, 128) . &#39;...&#39;;
$row[&#39;lastBody&#39;] = strip_tags(strtr(parse_bbc($row[&#39;lastBody&#39;], $row[&#39;lastSmileys&#39;], $row[&#39;ID_LAST_MSG&#39;]), array(&#39;<br />&#39; => &#39;&#39;)));
if (
$func[&#39;strlen&#39;]($row[&#39;lastBody&#39;]) > 128)
$row[&#39;lastBody&#39;] = $func[&#39;substr&#39;]($row[&#39;lastBody&#39;], 0, 128) . &#39;...&#39;;

// Censor the subject and message preview.
censorText(
$row[&#39;firstSubject&#39;]);
censorText(
$row[&#39;firstBody&#39;]);

// Don&#39;t censor them twice!
if (
$row[&#39;ID_FIRST_MSG&#39;] == $row[&#39;ID_LAST_MSG&#39;])
{
$row[&#39;lastSubject&#39;] = $row[&#39;firstSubject&#39;];
$row[&#39;lastBody&#39;] = $row[&#39;firstBody&#39;];
}
else
{
censorText(
$row[&#39;lastSubject&#39;]);
censorText(
$row[&#39;lastBody&#39;]);
}

// Decide how many pages the topic should have.
$topic_length = $row[&#39;numReplies&#39;] + 1;

if (
$topic_length > $modSettings[&#39;defaultMaxMessages&#39;])
{
$tmppages = array();
$tmpa = 1;
for (
$tmpb = 0; $tmpb < $topic_length$tmpb += $modSettings[&#39;defaultMaxMessages&#39;])
{
$tmppages[] = &#39;<a href="&#39; . $scripturl . &#39;?topic=&#39; . $row[&#39;ID_TOPIC&#39;] . &#39;.&#39; . $tmpb . &#39;">&#39; . $tmpa . &#39;</a>&#39;;
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = &#39;« &#39; . implode(&#39; &#39;, $tmppages);
// Or skip a few?
else
$pages = &#39;« &#39; . $tmppages[0] . &#39; &#39; . $tmppages[1] . &#39; ... &#39; . $tmppages[count($tmppages) - 2] . &#39; &#39; . $tmppages[count($tmppages) - 1];

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

// We need to check the topic icons exist...
if (empty($modSettings[&#39;messageIconChecks_disable&#39;]))
{
if (!isset($context[&#39;icon_sources&#39;][$row[&#39;firstIcon&#39;]]))
$context[&#39;icon_sources&#39;][$row[&#39;firstIcon&#39;]] = file_exists($settings[&#39;theme_dir&#39;] . &#39;/images/post/&#39; . $row[&#39;firstIcon&#39;] . &#39;.gif&#39;) ? &#39;images_url&#39; : &#39;default_images_url&#39;;
if (!isset($context[&#39;icon_sources&#39;][$row[&#39;lastIcon&#39;]]))
$context[&#39;icon_sources&#39;][$row[&#39;lastIcon&#39;]] = file_exists($settings[&#39;theme_dir&#39;] . &#39;/images/post/&#39; . $row[&#39;lastIcon&#39;] . &#39;.gif&#39;) ? &#39;images_url&#39; : &#39;default_images_url&#39;;
}
else
{
if (!isset($context[&#39;icon_sources&#39;][$row[&#39;firstIcon&#39;]]))
$context[&#39;icon_sources&#39;][$row[&#39;firstIcon&#39;]] = &#39;images_url&#39;;
if (!isset($context[&#39;icon_sources&#39;][$row[&#39;lastIcon&#39;]]))
$context[&#39;icon_sources&#39;][$row[&#39;lastIcon&#39;]] = &#39;images_url&#39;;
}

$return[$row[&#39;ID_TOPIC&#39;]] = array(
&#39;id&#39; => $row[&#39;ID_TOPIC&#39;],
&#39;board_link&#39; => &#39;<a href="&#39; . $scripturl . &#39;?board=&#39; . $row[&#39;ID_BOARD&#39;] . &#39;.0">&#39; . $row[&#39;name&#39;] . &#39;</a>&#39;,
&#39;first_post&#39; => array(
&#39;id&#39; => $row[&#39;ID_FIRST_MSG&#39;],
&#39;member&#39; => array(
&#39;username&#39; => $row[&#39;firstMemberName&#39;],
&#39;name&#39; => $row[&#39;firstDisplayName&#39;],
&#39;id&#39; => $row[&#39;firstID_MEMBER&#39;],
&#39;href&#39; => !empty($row[&#39;firstID_MEMBER&#39;]) ? $scripturl . &#39;?action=profile;u=&#39; . $row[&#39;firstID_MEMBER&#39;] : &#39;&#39;,
&#39;link&#39; => !empty($row[&#39;firstID_MEMBER&#39;]) ? &#39;<a href="&#39; . $scripturl . &#39;?action=profile;u=&#39; . $row[&#39;firstID_MEMBER&#39;] . &#39;" title="&#39; . $txt[92] . &#39; &#39; . $row[&#39;firstDisplayName&#39;] . &#39;">&#39; . $row[&#39;firstDisplayName&#39;] . &#39;</a>&#39; : $row[&#39;firstDisplayName&#39;]
),
&#39;time&#39; => timeformat($row[&#39;firstPosterTime&#39;]),
&#39;timestamp&#39; => forum_time(true, $row[&#39;firstPosterTime&#39;]),
&#39;subject&#39; => $row[&#39;firstSubject&#39;],
&#39;preview&#39; => $row[&#39;firstBody&#39;],
&#39;icon&#39; => $row[&#39;firstIcon&#39;],
&#39;icon_url&#39; => $settings[$context[&#39;icon_sources&#39;][$row[&#39;firstIcon&#39;]]] . &#39;/post/&#39; . $row[&#39;firstIcon&#39;] . &#39;.gif&#39;,
&#39;href&#39; => $scripturl . &#39;?topic=&#39; . $row[&#39;ID_TOPIC&#39;] . &#39;.0&#39;,
&#39;link&#39; => &#39;<a href="&#39; . $scripturl . &#39;?topic=&#39; . $row[&#39;ID_TOPIC&#39;] . &#39;.0">&#39; . $row[&#39;firstSubject&#39;] . &#39;</a>&#39;
),
&#39;last_post&#39; => array(
&#39;id&#39; => $row[&#39;ID_LAST_MSG&#39;],
&#39;member&#39; => array(
&#39;username&#39; => $row[&#39;lastMemberName&#39;],
&#39;name&#39; => $row[&#39;lastDisplayName&#39;],
&#39;id&#39; => $row[&#39;lastID_MEMBER&#39;],
&#39;href&#39; => !empty($row[&#39;lastID_MEMBER&#39;]) ? $scripturl . &#39;?action=profile;u=&#39; . $row[&#39;lastID_MEMBER&#39;] : &#39;&#39;,
&#39;link&#39; => !empty($row[&#39;lastID_MEMBER&#39;]) ? &#39;<a href="&#39; . $scripturl . &#39;?action=profile;u=&#39; . $row[&#39;lastID_MEMBER&#39;] . &#39;">&#39; . $row[&#39;lastDisplayName&#39;] . &#39;</a>&#39; : $row[&#39;lastDisplayName&#39;]
),
&#39;time&#39; => timeformat($row[&#39;lastPosterTime&#39;]),
&#39;timestamp&#39; => forum_time(true, $row[&#39;lastPosterTime&#39;]),
&#39;subject&#39; => $row[&#39;lastSubject&#39;],
&#39;preview&#39; => $row[&#39;lastBody&#39;],
&#39;icon&#39; => $row[&#39;lastIcon&#39;],
&#39;icon_url&#39; => $settings[$context[&#39;icon_sources&#39;][$row[&#39;lastIcon&#39;]]] . &#39;/post/&#39; . $row[&#39;lastIcon&#39;] . &#39;.gif&#39;,
&#39;href&#39; => $scripturl . &#39;?topic=&#39; . $row[&#39;ID_TOPIC&#39;] . ($row[&#39;numReplies&#39;] == 0 ? &#39;.0&#39; : &#39;.msg&#39; . $row[&#39;ID_LAST_MSG&#39;]) . &#39;#new&#39;,
&#39;link&#39; => &#39;<a href="&#39; . $scripturl . &#39;?topic=&#39; . $row[&#39;ID_TOPIC&#39;] . ($row[&#39;numReplies&#39;] == 0 ? &#39;.0&#39; : &#39;.msg&#39; . $row[&#39;ID_LAST_MSG&#39;]) . &#39;#new">&#39; . $row[&#39;lastSubject&#39;] . &#39;</a>&#39;
),
&#39;is_sticky&#39; => !empty($modSettings[&#39;enableStickyTopics&#39;]) && !empty($row[&#39;isSticky&#39;]),
&#39;is_locked&#39; => !empty($row[&#39;locked&#39;]),
&#39;is_poll&#39; => $modSettings[&#39;pollMode&#39;] == &#39;1&#39; && $row[&#39;ID_POLL&#39;] > 0,
&#39;is_hot&#39; => $row[&#39;numReplies&#39;] >= $modSettings[&#39;hotTopicPosts&#39;],
&#39;is_very_hot&#39; => $row[&#39;numReplies&#39;] >= $modSettings[&#39;hotTopicVeryPosts&#39;],
&#39;is_posted_in&#39; => false,
&#39;icon&#39; => $row[&#39;firstIcon&#39;],
&#39;icon_url&#39; => $settings[$context[&#39;icon_sources&#39;][$row[&#39;firstIcon&#39;]]] . &#39;/post/&#39; . $row[&#39;firstIcon&#39;] . &#39;.gif&#39;,
&#39;subject&#39; => $row[&#39;firstSubject&#39;],
&#39;new&#39; => $row[&#39;new_from&#39;] <= $row[&#39;ID_MSG_MODIFIED&#39;],
&#39;new_from&#39; => $row[&#39;new_from&#39;],
&#39;newtime&#39; => $row[&#39;new_from&#39;],
&#39;new_href&#39; => $scripturl . &#39;?topic=&#39; . $row[&#39;ID_TOPIC&#39;] . &#39;.msg&#39; . $row[&#39;new_from&#39;] . &#39;#new&#39;,
&#39;pages&#39; => $pages,
&#39;replies&#39; => $row[&#39;numReplies&#39;],
&#39;views&#39; => $row[&#39;numViews&#39;]
);

determineTopicClass($return[$row[&#39;ID_TOPIC&#39;]]);
}

mysql_free_result($result);

return $return;
}

// Helper functions
function initRelated()
{
global $context$modSettings$sourcedir;

if (isset($context[&#39;relatedClass&#39;]))
return;

$indexType ucwords($modSettings[&#39;relatedIndex&#39;]);
$class = &#39;RelatedTopics&#39; . $indexType;

require_once($sourcedir . &#39;/Subs-Related&#39; . $indexType . &#39;.php&#39;);

$context[&#39;relatedClass&#39;] = new $class;
}

// Search for related topics by subject
function searchRelated($id_topic$subject$score false)
{
global $scripturl$txt$db_prefix$modSettings$context$sourcedir;
global $user_info$smfFunc$sourcedir;

if (!isset($context[&#39;relatedClass&#39;]))
initRelated();

return $context[&#39;relatedClass&#39;]->searchRelated($id_topic, $subject, $score);
}

// Create / update relations
function createRelations($id_topic$subject)
{
global $scripturl$txt$db_prefix$modSettings$context;
global $user_info;

$ids searchRelated($id_topic$subjecttrue);

if (empty($ids))
return false;

// 10 should be okay
$ids array_slice($ids010);

$string = &#39;&#39;;

foreach ($ids as $id)
if ($id_topic != $id[0])
$string .= &#39;
(&#39; . min($id_topic, $id[0]) . &#39;, &#39; . max($id_topic, $id[0]) . &#39;, &#39; . $id[1] . &#39;),&#39;;

if (empty($string))
return false;

$result db_query("
INSERT IGNORE INTO 
{$db_prefix}related_topics
(id_topic_first, id_topic_second, score)
VALUES" 
substr($string0, -1), __FILE____LINE__);

return true;
}

// Add new thread to cache
function addRelated($topics$subject = &#39;&#39;, $remove = false)
{
global $scripturl$txt$db_prefix$modSettings$context$sourcedir;
global $user_info;

if (!isset($context[&#39;relatedClass&#39;]))
initRelated();

if (!$remove)
removeRelated($topics);

$context[&#39;relatedClass&#39;]->addToCache($topics, $subject);

if (!$remove)
{
if (is_array($topics))
{
foreach ($topics as $t)
createRelations($t[0], $t[1]);
}
else
{
createRelations($topics$subject);
}
}
}

// Remove related
function removeRelated($topics)
{
global $txt$db_prefix$modSettings$context$sourcedir;

if (!isset($context[&#39;relatedClass&#39;]))
initRelated();

if (!is_array($topics))
$topics = array($topics);

if (empty($topics))
return true;

$context[&#39;relatedClass&#39;]->removeFromCache($topics);

$topics implode(&#39;, &#39;, $topics);

db_query("
DELETE FROM 
{$db_prefix}related_topics
WHERE id_topic_first IN(
$topics) OR id_topic_second IN ($topics)"__FILE____LINE__);

return true;
}

?>




ต่อไปตั้งชื่อว่า Subs-RelatedFulltext.php

โค๊ด:
<?php
/**********************************************************************************
* Subs-RelatedFulltext.php                                                        *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under   *
* the terms of the provided license as published by Simple Machines LLC.          *
*                                                                                 *
* This program is distributed in the hope that it is and will be useful, but      *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY    *
* or FITNESS FOR A PARTICULAR PURPOSE.                                            *
*                                                                                 *
* See the "license.txt" file for details of the Simple Machines license.          *
* The latest version can always be found at http://www.simplemachines.org.        *
**********************************************************************************/

class RelatedTopicsFulltext
{
function __construct()
{
}

function recreateIndexTables()
{
global $smcFunc$db_prefix;

db_query("
DROP TABLE IF EXISTS 
{$db_prefix}related_subjects"__FILE____LINE__);

db_query("
CREATE TABLE IF NOT EXISTS 
{$db_prefix}related_subjects (
id_topic int(10) unsigned NOT NULL,
subject tinytext NOT NULL,
PRIMARY KEY (id_topic),
FULLTEXT KEY subject (subject)
)"
__FILE____LINE__);


return true;
}

function addToCache($topics$subject = &#39;&#39;)
{
global $db_prefix;

if (!is_array($topics))
$topics = array(
array((int) $topics$subject)
);

foreach ($topics as $topic)
{
$subject mysql_real_escape_string($topic[1]);

db_query("
INSERT INTO 
{$db_prefix}related_subjects
(id_topic, subject)
VALUES
(
$topic[0], &#39;$subject&#39;)"__FILE____LINE__);
}

return true;
}

function removeFromCache($topics)
{
global $db_prefix;

$topics implode(&#39;, &#39;, $topics);

db_query("
DELETE FROM 
{$db_prefix}related_subjects
WHERE ID_TOPIC IN(
$topics)"__FILE____LINE__);

return true;
}

function searchRelated($id_topic$subject$score false)
{
global $db_prefix;

$subject mysql_real_escape_string($subject);

$result db_query("
SELECT rs.id_topic, MATCH(rs.subject) AGAINST(&#39;
$subject&#39;) AS score
FROM 
{$db_prefix}related_subjects AS rs
WHERE MATCH(rs.subject) AGAINST(&#39;
$subject&#39;)
ORDER BY MATCH(rs.subject) AGAINST(&#39;
$subject&#39;) DESC"__FILE____LINE__);

$return = array();

while ($row mysql_fetch_assoc($result))
{
if (!$score)
$return[] = $row[&#39;id_topic&#39;];
else
$return[] = array($row[&#39;id_topic&#39;], $row[&#39;score&#39;]);
}
mysql_free_result($result);

return $return;
}
}

?>



ไฟล์ทั้ง 2 อัพขึ้นไปไว้ที่ board/Source/ นะครับ



ต่อไปสร้างไฟล์ ชื่อ related_topics.php อัพไปไว้ที่เดียวกับ SSI.php

โค๊ด:
<?php
/*******************************************************************************
This is script for installing Related Topics

ATTENTION: If you are trying to INSTALL this package, please access
it directly, with a URL like the following:
http://www.yourdomain.tld/forum/related_topics.php (or similar.)

*******************************************************************************/
global $db_prefix;

// If SSI.php is in the same place as this file, and SMF isn&#39;t defined, this is being run standalone.
if (file_exists(dirname(__FILE__) . &#39;/SSI.php&#39;) && !defined(&#39;SMF&#39;))
require_once(dirname(__FILE__) . &#39;/SSI.php&#39;);
// Hmm... no SSI.php and no SMF?
elseif (!defined(&#39;SMF&#39;))
die(&#39;<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\&#39;s index.php.&#39;);

$overwrite_old_settings false;

$mod_settings = array(
&#39;relatedTopicsEnabled&#39; => &#39;1&#39;,
&#39;relatedTopicsCount&#39; => &#39;5&#39;,
&#39;relatedIndex&#39; => &#39;fulltext&#39;
);

// Turn the array defined above into a string of MySQL data.
$string = &#39;&#39;;
foreach ($mod_settings as $k => $v)
$string .= &#39;
(\&#39;&#39; . $k . &#39;\&#39;, \&#39;&#39; . $v . &#39;\&#39;),&#39;;

// Sorted out the array defined above - now insert the data!
if ($string != &#39;&#39;)
$result db_query("
. ($overwrite_old_settings ? &#39;REPLACE&#39; : &#39;INSERT IGNORE&#39;) . " INTO {$db_prefix}settings
(variablevalue)
VALUES" . substr($string, 0, -1), __FILE__, __LINE__);

// Uh-oh spaghetti-oh!
if (
$result === false)
echo &#39;<b>Error:</b> Database modifications failed!&#39;;

db_query("
CREATE TABLE IF NOT EXISTS {$db_prefix}related_topics (
id_topic_first int(10unsigned NOT NULL,
id_topic_second int(10unsigned NOT NULL,
score float unsigned NOT NULL,
PRIMARY KEY (id_topic_firstid_topic_second)
)", __FILE__, __LINE__);

?>


เสร็จแล้วเรียกไฟล์นี้เลยครับ เช่น http://localhost/board/related_topics.php



การตั้งต่าใช้งาน

ผู้ดูแล >> ส่วนปรับแต่งค่าการใช้งาน >>

- มองหา Enable Related Topics ติ๊กถูกเลย
- ส่วน How many related topics to show ใส่เท่าไรก็ได้ครับแนะนำ 5 ก็พอครับ

ต่อไปสิ่งที่ลืมไม่ได้เลย มองหา Build index  ถ้าเจอแล้วก็ Click 1 ทีครับ


จบแล้วครับ ขอให้สนุกกับการปรับแต่งนะครับ
บันทึกการเข้า

Ruk-Com Hosting (IAAS)
Ruk-Com Cloud (PAAS)
รีวิวโฮสติ่ง Ruk-Com  จากสมาชิก THAISEO

ไม่พอใจยินดีคืนเงินเต็มจำนวนทุกบริการ
Reality
สมุนแก๊งเสียว
*

พลังน้ำใจ: 51
ออฟไลน์ ออฟไลน์

กระทู้: 757



ดูรายละเอียด เว็บไซต์
« ตอบ #1 เมื่อ: 18 มกราคม 2010, 05:34:59 »

+ ให้นะ น้องรัก(เหรอ ?!) wanwan016
บันทึกการเข้า

*You walk right into reality, While my heart's still wild and free.. 

Midnight Adventure
Putter™
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 421
ออฟไลน์ ออฟไลน์

กระทู้: 2,104



ดูรายละเอียด เว็บไซต์
« ตอบ #2 เมื่อ: 18 มกราคม 2010, 14:08:35 »

ผมรักน้องโฟกัสครับ  wanwan004 wanwan004
บันทึกการเข้า

Ruk-Com Hosting (IAAS)
Ruk-Com Cloud (PAAS)
รีวิวโฮสติ่ง Ruk-Com  จากสมาชิก THAISEO

ไม่พอใจยินดีคืนเงินเต็มจำนวนทุกบริการ
Reality
สมุนแก๊งเสียว
*

พลังน้ำใจ: 51
ออฟไลน์ ออฟไลน์

กระทู้: 757



ดูรายละเอียด เว็บไซต์
« ตอบ #3 เมื่อ: 18 มกราคม 2010, 14:11:28 »

ผมรักน้องโฟกัสครับ  wanwan004 wanwan004
เห้ยไม่น่า + เลยวะ (มีกดลบไหมครับ)

คนนั้นแฟนผมครับ ขอร้องอย่าง wanwan015

 wanwan004 wanwan004
บันทึกการเข้า

*You walk right into reality, While my heart's still wild and free.. 

Midnight Adventure
tonzatatay
สมุนแก๊งเสียว
*

พลังน้ำใจ: 55
ออฟไลน์ ออฟไลน์

กระทู้: 900



ดูรายละเอียด เว็บไซต์
« ตอบ #4 เมื่อ: 18 มกราคม 2010, 14:14:25 »

วิทยายุทธยังล้ำเลิสเหมือนเดิม     wanwan016
บันทึกการเข้า

tonzatatay
สมุนแก๊งเสียว
*

พลังน้ำใจ: 55
ออฟไลน์ ออฟไลน์

กระทู้: 900



ดูรายละเอียด เว็บไซต์
« ตอบ #5 เมื่อ: 18 มกราคม 2010, 18:37:32 »

วิทยายุทธยังล้ำเลิสเหมือนเดิม     wanwan016


ว่าแต่มันคืออะไรคับ เอา title มาทำเป็นลิ้งหลอ
บันทึกการเข้า

honghong
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 114
ออฟไลน์ ออฟไลน์

กระทู้: 1,267



ดูรายละเอียด
« ตอบ #6 เมื่อ: 18 มกราคม 2010, 19:05:20 »

วิทยายุทธยังล้ำเลิสเหมือนเดิม     wanwan016


ว่าแต่มันคืออะไรคับ เอา title มาทำเป็นลิ้งหลอ
มาช่วยตอบครับมันคือ
related topic
ง่ายก็คือกระทู้ที่เกี่ยวข้องครับ
มันจะให้เราเลือกได้ว่าจะให้บทความเกี่ยวข้องกี่บทความ
แล้วมาลงตรงที่บอร์คล่างสุดตามตัวอย่าง
เวลาคนอ่านบทความในบอร์คจบก็จะมีกระทู้ข่างเคียงมาครับ

เหมือนของwordpress ที่มีmod บทความที่เกี่ยวข้องน่ะครับ
บันทึกการเข้า
popsiam
สมุนแก๊งเสียว
*

พลังน้ำใจ: 43
ออฟไลน์ ออฟไลน์

กระทู้: 807



ดูรายละเอียด
« ตอบ #7 เมื่อ: 18 มกราคม 2010, 19:16:00 »

ขอบคุณครับ
บันทึกการเข้า
xaax
ก๊วนเสียว
*

พลังน้ำใจ: 30
ออฟไลน์ ออฟไลน์

กระทู้: 459



ดูรายละเอียด เว็บไซต์
« ตอบ #8 เมื่อ: 18 ธันวาคม 2010, 10:57:42 »

เสิร์ซหาข้อมูลใน Google มาเจอกระทู้นี้พอดี ขออภัยที่ต้องขุด แต่อยากจะบอกว่า ขอบคุณมากครับ  wanwan017
บันทึกการเข้า

หน้า: [1]   ขึ้นบน
พิมพ์