280
« เมื่อ: 28/10/05, 11:02:50 »
ลองเปิดไฟล์ Mod ด้วย Notepad นะคะ
แล้วไล่อ่านโค้ดดูว่า Mod ตัวนั้นจะมีการแก้ไขไฟล์ไหนบ้าง ก็ให้เราก็เปิดไฟลืนั้นๆขึ้นมาแก้ไขเองค่ะ
<id>
HideTag_10
</id>
<version>
1.00
</version>
<mod info>
Add Hide Tag in Post Message.
</mod info>
<author>
ThaiAnime
</author>
<homepage>
http://helloproject.thaianime.net
</homepage>
<edit file>
Sources/Subs.php
</edit file>
<search>
global $modSettings, $scripturl, $txt, $settings, $context;
</search>
<replace>
global $modSettings, $scripturl, $txt, $settings, $context;
global $ID_MEMBER, $db_prefix, $user_info;
</replace>
<search>
// Moving text... [move]stuff[/move]
</search>
<replace>
// [hide]Guests cannot see this! Mwahaha![/hide]
$codefromcache[] = '~\[hide\](.+?)\[/hide\]~i';
if ($disabled['hide'] || $user_info['is_admin'])
$codetocache[] = $txt['hide_tag'] . '<br><div class="code"> $1</div>';
else
{
if (!empty($context['current_topic']) && !$user_info['is_guest'])
{
$request = mysql_query("
SELECT ID_MSG FROM {$db_prefix}messages
WHERE ID_MEMBER = $ID_MEMBER
AND ID_TOPIC = $context[current_topic]
LIMIT 1");
if (mysql_num_rows($request))
$codetocache[] = $txt['hide_tag'] . '<br><div class="code"> $1</div>';
else
$codetocache[] = $txt['hide_tag'] . '<br><div class="code">' . $txt['hide_tag_a'] . '</div>';
mysql_free_result($request);
}
else
$codetocache[] = $txt['hide_tag'] . '<br><div class="code">' . $txt['hide_tag_b'] . '</div>';
}
// Moving text... [move]stuff[/move]
</replace>
<edit file>
Themes/default/languages/Modifications.english.php
</edit file>
<search>
?>
</search>
<replace>
//Hide Tag
$txt['hide_tag'] = 'Hide Message :';
$txt['hide_tag_a'] = 'This message is hidden from users who have not posted in this topic. To get rid of this and see the actual message, you must reply to the topic.';
$txt['hide_tag_b'] = 'This message is hidden from guests. To get rid of this and see the actual message, you must register or login, and then reply to the topic.';
?>
</replace>
<edit file>
Themes/default/languages/Modifications.thai.php
</edit file>
<search>
?>
</search>
<replace>
//ซ่อนข้อความ
$txt['hide_tag'] = '<b>ข้อความที่ถูกซ่อน :</b> ';
$txt['hide_tag_a'] = 'ข้อความนี้ได้ถูกซ่อน คุณต้องโพสตอบหัวข้อนี้ก่อน.';
$txt['hide_tag_b'] = 'ข้อความนี้ได้ถูกซ่อน <b>บุคคลทั่วไป</b>ถ้าต้องการดูข้อความให้คุณ<a href="index.php?action=register">สมัครสมาชิก</a>หรือ<a href="index.php?action=login">เข้าสู่ระบบ</a>ก่อน แล้วตอบหัวข้อนี้.';
?>
</replace>
อย่างด้านบนเป็นตัวอย่าง Mod สำหรับซ่อนข้อความในบอร์ด (อันนี้เก่ามากแล้วค่ะ SMF เวอร์ชั่นใหม่ๆไม่แน่ใจว่าใช้ได้หรือเปล่า)
จุดหลักๆก็ดูตามนี้น่ะค่ะ
<edit file> ... จะบอกชื่อไฟล์ที่ต้องทำการแก้ไข
<search> ... หาส่วนที่จะทำการแก้ไขออกมา
<replace> ... ใช้ข้อความในส่วนนี้วางทับในส่วนของ Search ที่หาออกมาได้ค่ะ
บางไฟล์อาจจะมี <add after> ก็ใช้หลักการเดียวกันนี้ทำการแก้ไขไฟล์ค่ะ
ลองดูก่อนนะคะ