วันอังคารที่ 26 มิถุนายน พ.ศ. 2555

[MOD] แค่แปะลิงค์ของวีดีโอ..วีดีโอก็แสดง


วันนี้มาแนะนำ mod สักตัวเอาแบบสั้นๆ ง่ายๆ ได้ใจความ


สรรพคุณคือสำหรับโพสต์คลิป หรือวีดีโอ ไม่ว่าจะมาจากยูทูป หรือจากเจ้าอื่นๆ ก็ได้
เคยแนะนำมอดสำหรับโพสต์คลิปไปแล้ว แต่ตัวนั้นโพสต์คลิปจากยูทูปเท่านั้น
ตัวนี้เด็ดกว่านั้นครับ เพราะมันรองรับได้ทุกสัญชาติ และที่เด็กกว่าอีก นั่นคือ
วิธีโพสต์แสนง่ายมาก แค่เอาลิงค์ของคลิป หรือวีดิโอมาแปะไว้ช่องโพสต์กระทู้ มันก็จะทำการ Embed แสดงผลในรูปวีดีโอให้เราโดยอัตโนมัติเลยละครับ

รองรับ SMF ทุกเวอร์ชั่น !! 
จงไปเสพ ณ บัดนาวเลย

http://custom.simplemachines.org/mods/index.php?mod=977

วันจันทร์ที่ 25 มิถุนายน พ.ศ. 2555

[SMF] เพิ่มพื้นที่กระทู้กว้างขึ้น ด้วยการดึงข้อมูลผู้ตั้ง/ผู้ตอบกระทู้ไว้ด้านบน

บอร์ดเกี่ยวกับการถ่ายรูป ส่วนใหญ่ต้องการโชว์ภาพใหญ่ๆ ดังนั้น จึงอยากจะเอาข้อมูลของคนตอบหรือคนตั้งกระทู้จากเดิมอยู่ด้านซ้าย 
อยากย้ายไปด้านบนซะ ..ทำยังไงดี?


วันนี้ผมมีวิธีครับ
เปิดไฟล์ Themes/yourthemes/Display.template.php

ค้นหาคำสั่งนี้  // Show information about the poster of this message. เจอแล้วอย่าพึ่งทำอะไร
หาคำสั่งนี้ต่อเลย  // Show the post itself, finally!

ให้ลบคำสั่งตั้งแต่  // Show information about the poster of this message.  ลงมาจนถึง   // Show the post itself, finally! เลยครับ
แล้วเพิ่มคำสั่งนี้ไปแทนที่



    // Show information about the poster of this message.
echo '
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
<tr>
<td bgcolor="#444">';


    // Show avatars, images, etc.?
if (!empty($settings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
echo '
        <div class="profileINFO">', $message['member']['avatar']['image'],'<br>';
       
       
                // Show their personal text?
if (!empty($settings['show_blurb']) && $message['member']['blurb'] != '')
echo '
        ', $message['member']['blurb'], '<br />
        <br />';

// This shows the popular messaging icons.
echo '
        ', $message['member']['icq']['link'], '
        ', $message['member']['msn']['link'], '
        ', $message['member']['aim']['link'], '
        ', $message['member']['yim']['link'], '<br />';
       
            // Show the profile, website, email address, and personal message buttons.
if ($settings['show_profile_buttons'])
{
// Don't show the profile button if you're not allowed to view the profile.
if ($message['member']['can_view_profile'])
echo '
        <a href="', $message['member']['href'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/icons/profile_sm.gif" alt="' . $txt[27] . '" title="' . $txt[27] . '" border="0" />' : $txt[27]), '</a>';

// Don't show an icon if they haven't specified a website.
if ($message['member']['website']['url'] != '')
echo '
        <a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/www_sm.gif" alt="' . $txt[515] . '" border="0" />' : $txt[515]), '</a>';

// Don't show the email address if they want it hidden.

if (empty($message['member']['hide_email']))
echo '
        <a href="mailto:', $message['member']['email'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/email_sm.gif" alt="' . $txt[69] . '" title="' . $txt[69] . '" border="0" />' : $txt[69]), '</a>';

// Since we know this person isn't a guest, you *can* message them.

if ($context['can_send_pm'])
echo '
        <a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['label'], '">', $settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . '.gif" alt="' . $message['member']['online']['label'] . '" border="0" />' : $message['member']['online']['label'], '</a>';
       
       
}
       
        echo '</div> ';

echo '<div style="float:left;padding: 5px; 10px">';

echo' <b>', $message['member']['link'], '</b>
    <div class="smalltext">';

// Show the member's custom title, if they have one.
if (isset($message['member']['title']) && $message['member']['title'] != '')
echo '
        ', $message['member']['title'], '<br />';

// Show the member's primary group (like 'Administrator') if they have one.
if (isset($message['member']['group']) && $message['member']['group'] != '')
echo '
        ', $message['member']['group'], '<br />';

// Don't show these things for guests.
if (!$message['member']['is_guest'])
{
// Show the post group if and only if they have no other group or the option is on, and they are in a post group.
if ((empty($settings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '')
echo '
        ', $message['member']['post_group'], '<br />';
echo '
        ', $message['member']['group_stars'], '<br />';

// Is karma display enabled?  Total or +/-?
if ($modSettings['karmaMode'] == '1')
echo '
        <br />
        ', $modSettings['karmaLabel'], ' ', $message['member']['karma']['good'] - $message['member']['karma']['bad'], '<br />';
elseif ($modSettings['karmaMode'] == '2')
echo '
        <br />
        ', $modSettings['karmaLabel'], ' +', $message['member']['karma']['good'], '/-', $message['member']['karma']['bad'], '<br />';

// Is this user allowed to modify this member's karma?
if ($message['member']['karma']['allow'])
echo '
        <a href="', $scripturl, '?action=modifykarma;sa=applaud;uid=', $message['member']['id'], ';topic=', $context['current_topic'], '.' . $context['start'], ';m=', $message['id'], ';sesc=', $context['session_id'], '">', $modSettings['karmaApplaudLabel'], '</a>
        <a href="', $scripturl, '?action=modifykarma;sa=smite;uid=', $message['member']['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';m=', $message['id'], ';sesc=', $context['session_id'], '">', $modSettings['karmaSmiteLabel'], '</a><br />';

// Show online and offline buttons?
if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])
echo '
        ', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', $settings['use_image_buttons'] ? '<img src="' . $message['member']['online']['image_href'] . '" alt="' . $message['member']['online']['text'] . '" border="0" style="margin-top: 2px;" />' : $message['member']['online']['text'], $context['can_send_pm'] ? '</a>' : '', $settings['use_image_buttons'] ? '<span class="smalltext"> ' . $message['member']['online']['text'] . '</span>' : '', '<br /><br />';

// Show the member's gender icon?
if (!empty($settings['show_gender']) && $message['member']['gender']['image'] != '')
echo '
        ', $txt[231], ': ', $message['member']['gender']['image'], '<br />';

// Show how many posts they have made.
echo '
        ', $txt[26], ': ', $message['member']['posts'], '<br />
        <br />';

}
// Otherwise, show the guest's email.
elseif (empty($message['member']['hide_email']))
echo '
        <br />
        <br />
    <a href="mailto:', $message['member']['email'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/email_sm.gif" alt="' . $txt[69] . '" title="' . $txt[69] . '" border="0" />' : $txt[69]), '</a>';

// Done with the information about the poster... on to the post itself.
echo '
    </div>
</td>
</tr>



<tr>
<td valign="top" width="100%" height="100%">
    <table width="100%" border="0"><tr>
        <td valign="middle"><a href="', $message['href'], '"><img src="', $message['icon_url'] . '" alt="" border="0" /></a></td>
        <td valign="middle">
            <div style="font-weight: bold;" id="subject_', $message['id'], '">
                <a href="', $message['href'], '">', $message['subject'], '</a>
            </div>';

// If this is the first post, (#0) just say when it was posted - otherwise give the reply #.
echo '
            <div class="smalltext">« <b>', !empty($message['counter']) ? $txt[146] . ' #' . $message['counter'] : '', ' ', $txt[30], ':</b> ', $message['time'], ' »</div></td>
        <td align="', !$context['right_to_left'] ? 'right' : 'left', '" valign="bottom" height="20" style="font-size: smaller;">';

// Can they reply? Have they turned on quick reply?
if ($context['can_reply'] && !empty($options['display_quick_reply']))
echo '
<a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';num_replies=', $context['num_replies'], ';sesc=', $context['session_id'], '" onclick="doQuote(', $message['id'], ', \'', $context['session_id'], '\'); return false;">', $reply_button, '</a>';

// So... quick reply is off, but they *can* reply?
elseif ($context['can_reply'])
echo '
<a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';num_replies=', $context['num_replies'], ';sesc=', $context['session_id'], '">', $reply_button, '</a>';

// Can the user modify the contents of this post?
if ($message['can_modify'])
echo '
<a href="', $scripturl, '?action=post;msg=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';sesc=', $context['session_id'], '">', $modify_button, '</a>';

// How about... even... remove it entirely?!
if ($message['can_remove'])
echo '
<a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';sesc=', $context['session_id'], '" onclick="return confirm(\'', $txt[154], '?\');">', $remove_button, '</a>';

// What about splitting it off the rest of the topic?
if ($context['can_split'])
echo '
<a href="', $scripturl, '?action=splittopics;topic=', $context['current_topic'], '.0;at=', $message['id'], '">', $split_button, '</a>';

// Can do some Thank You Post things :)
if ($message['thank_you_post']['post'] && !$message['thank_you_post']['locked'])
echo '
<a href="', $scripturl, '?action=thankyou;topic=', $context['current_topic'], '.0;msg=', $message['id'], '">', $thankyoupostpost_button, '</a>';

if ($message['thank_you_post']['lock'] && $message['thank_you_post']['isThankYouPost'])
echo '
<a href="', $scripturl, '?action=thankyoupostlock;topic=', $context['current_topic'], '.0;msg=', $message['id'], '">', $message['thank_you_post']['locked'] ? $thankyoupostopen_button : $thankyoupostlock_button, '</a>';

if ($message['thank_you_post']['delete'] && $message['thank_you_post']['isThankYouPost'])
echo '
<a href="', $scripturl, '?action=thankyoupostdelete;topic=', $context['current_topic'], '.0;msg=', $message['id'], ';sesc=', $context['session_id'], '" onclick="return confirm(\'', $txt['remove_thank_you_post'], '?\');">', $thankyoupostdelete_button, '</a>';

// Show a checkbox for quick moderation?
if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove'])
echo '
            <input type="checkbox" name="msgs[]" value="', $message['id'], '" class="check" ', empty($settings['use_tabs']) ? 'onclick="document.getElementById(\'quickmodSubmit\').style.display = \'\';"' : '', ' />';

// Show the post itself, finally!



ที่เหลือก็ไปปรับแต่งให้สวยงามตามใจชอบนะครับ
พยายามจะอธิบายขั้นตอนการแต่งให้ละเอียด แต่กลัวอธิบายแล้วจะงงไปกันใหญ่
เลยเอาง่ายๆ งี้ละกันนะ :o

[SMF] ลงMODไม่ได้ทำไงดี?




หลายครั้งที่เวลาจะลงมอดตัวใหญ่ๆ มักพบปัญหาลงไม่สำเร็จ แต่ลงในเครื่องสำเร็จดี ทั้งนี้สาเหตุเป็นเพราะอันใดหรือ? ช่วยชี้แจงแถลงไขที
ครับ, ปัญหานี้เป็นกันบ่อย เป็นกันเยอะ เป็นกันมาก จนบางคนหนีไปจาก SMF เลยทีเดียวเีชียว แต่ยังไงก็หนีไม่พ้นหรอกครับ ไปหา CMS เจ้าอื่นก็จะเจอปัญหาอื่นอีกไปเรื่อยๆ  เราไม่สามารถหนีปัญหาได้หรอกครับ
ต้องสู้กับมัน!!

สาเหตุที่ลงmod บนโฮสท์จริงแล้วไม่ค่อยผ่าน สาเหตุหลักมาจากไฟล์หรือโฟลเดอร์ของเราไม่ได้ set permission ให้เป็น 777 หรือให้เป็น writeable นั่นเองครับ
คำถามตามมาทันที แล้วจะต้องไปเซตไฟล์ไหนบ้าง?

อันนี้ตอบไม่ได้เลยครับ เพราะปลั๊กอินแต่ละตัวมีการเขียนไฟล์ไม่เหมือนกัน ไม่เท่ากัน บางมอดต้องสร้างตารางขึ้นมาใหม่ หรือเพิ่มฟิลด์ไปในตารางเดิม ฯลฯ
จะให้มานั่งไล่เซตไฟล์ให้เป็น 777 ก็ไม่ไหว เพราะบางไฟล์เซตไม่ได้อีก เพราะถูกทางโฮสท์fixไว้ไม่ให้แก้ไขหรือลบบางไฟล์

แล้วงี้..ต้องทำไง?

วิธีแก้ไขคือ ลงมอดในเครื่องเราก่อนครับ 
หลังจากลงเรียบร้อยแล้ว ก็ดูว่ามีการเขียนไปในไฟล์ไหนบ้าง เสร็จแล้วก็อัพไฟล์เหล่านั้นไปทับไฟล์เก่าบนโฮสท์จริง
หรือถ้ามีการสร้างตารางใหม่ด้วย เราก็ต้องเข้าไปสร้างตารางใหม่ โดยตั้งชื่อและสร้างฟิลด์ให้เหมือนในเครื่องเราเลยครับ

เพียงเท่านี้เราก็สามารถ install มอดใหญ่ได้อย่างไม่มีปัญหา (ถึงแม้ว่าจะยุ่งยากไปนิดก็ตาม!!)

วันพฤหัสบดีที่ 14 มิถุนายน พ.ศ. 2555

[SMF] ปัญหาระหว่างอัพเกรดเวอร์ชั่นของ SMF จากเวอร์ชั่น 1 สู่เวอร์ชั่น 2



เว็บบอร์ด smf ที่ใช้กันมานานแล้ว ส่วนใหญ่ก็จะใช้เวอร์ชั่น 1 กัน ทีนีพอ smf ออกเวอร์ชั่นใหม่มา นั่นคือเวอร์ชั่น 2 หลายๆคนก็อยากจะใช้เวอร์ชั่น 2 บ้าง 
แต่ก็ยังลังเลไม่กล้าอัพเกรด เพราะเกรงว่าข้อมูลในบอร์ดทั้งหมด ไม่ว่าจะเป็นรายชื่อสมาชิก หรือกระทู้ต่างๆนานามากมายจะอันตรธานหายไปในระหว่างการเปลี่ยนเวอร์ชั่น!!

เรื่องนี้เป็นสิ่งที่น่ากลัวครับ แต่เราก็สามารถขจัดความกลัวได้ ด้วยการแบกอัพข้อมูลก่อนอัพเกรด

แต่วันนี้จะมาแชร์ปัญหาที่เกิดขึ้นระหว่างอัพเกรด
หากเราอัพโหลดไฟล์ upgrade ขึ้นไปเรียบร้อยแล้ว นาทีนี้เราจะถอยหลังไม่ได้แล้ว ต้องเดินหน้าอัพเกรดอย่างเดียว
พออัพโหลดไฟล์เสร็จสรรพ เรียกหาไฟล์ upgrade.php ผ่านบราวเซอร์ ..ความระทึกใจอยู่ตรงนี้แหละครับ

หากเรียกแล้วมันขึ้นมาด้วยหน้าตาปกติ ดูดี ..เราก็หายใจทั่วท้อง มั่นใจได้ว่า การอัพเกรดครั้งนี้ต้องผ่านไปได้ด้วยดีอย่างแน่นอน !!

แต่ถ้าเรียกไฟล์ upgrade.php ผ่านบราวเซอร์ปุ๊บ หน้าตามันดูเอ่อๆ ผิดปกติ แถมยังมีแจ้งเอ่อเร่อแจ้งบรรทัดที่ผิดด้วย โอ้ย ตาย เราจะแก้ปัญหายังไงดี!!

ปัญหานี้เกิดขึ้นเพราะไฟล์ที่เราอัพโหลดไปนั้น ไม่สมบูรณ์!!
ทั้งๆที่เรามั่นใจว่าเราอัพโหลดไฟล์ไปทับไฟล์เก่าเรียบร้อยหมดแล้วนะ แต่ทำไม ถึงบอกว่าไม่สมบูรณ์

อย่างนี้ครับ ไฟล์บางไฟล์ถูกห้ามไม่ให้ลบหรือทับ ดังนั้น มันจึงยังคงเป็นไฟล์เก่าอยู่ พอเป็นไฟล์เก่า การอัพเกรดก็ไม่ผ่่าน!!

การแก้ปัญหาคือ ให้พยายามลบไฟล์นั้นให้ได้ครับ แต่ถ้าพยายามจนสุดความสามารถแล้วยังลบไม่ได้ ก็ให้ไปเปลี่ยนชื่อไฟล์ หรือโฟลเดอร์นั่นซะ แล้วค่อยอัพไฟล์ใหม่เข้าไปแทน

ทีนี้ ..ก็ค่อยทำการอัพเกรดต่อไป รับรองผ่าน ฉลุย !!

วันศุกร์ที่ 1 มิถุนายน พ.ศ. 2555

[SMF] วิธีทำกระทู้แนะนำในเว็บบอร์ด


อ้างอิงจากกระทู้นี้ http://forum.ubuntuclub.com/forum?topic=8915 ของ Ubuntuclub Forum  ครับ
เห็นว่าน่าสนใจดีเลยขออนุญาตนำมาเผยแพร่ต่อเผื่อให้ท่านที่สนใจ

กระทู้ที่อ้างอิงด้านบนนั่นกล่าวถึงการ "กระทู้แนะนำ" หรือกระทู้โหวต ซึ่งสามารถเขียนให้สมาชิกโหวต หรือเฉพาะแอดมินเท่านั้นที่โหวตก็ได้
แต่จากตัวอย่างลิงค์ด้านบน อนุญาตให้สมาชิกเท่านั้นโหวต  เพื่อให้กระทู้ขึ้นในหมวดกระทู้แนะนำ

ความจริงจะบอกว่าเป็นกระทู้โหวตก็ไม่ใคร่ถูกนัก เป็นเพียงการอนุญาตให้สมาชิกคลิกเลือกกระทู้ให้ไปอยู่ในหมวด "กระทู้แนะนำ" ซึ่งจะอยู่บนสุด แขกใครไปไหนมาไหนก็จะเห็นเด่นเป็นสง่า
ผมจะไม่เขียนอะไรเพิ่มเติมในระบบที่ทาง Ubuntuclub Forum  เขียนไว้แล้วนะครับ
แค่จะแนะนำวิธีใช้งานเท่านั้นเอง (ในลิงค์ดังกล่าวแนะนำการใช้งานไว้สำหรับทั้งเวอร์ชั่น 1 และเวอร์ชั่น 2 แต่ในที่นี้ผมจะขอพูดถึงเฉพาะเวอร์ชั่น 2 เท่านั้นนะครับ)

ถ้าท่านยังคิดภาพกระทู้แนะนำไม่ออก ..ก็ขอให้คิดถึงภาพเว็บบอร์ดที่มีกระทู้เรียงกันเป็นลำดับ แต่ด้านบนสุดของกระทู้ที่เรียงเป็นลำดับนั้น มีกล่องสี่เหลี่ยมตกแต่งสวยงาม ซึ่งในกล่องนั้นปรากฏกระทู้, ผู้ตั้งกระทู้, วันเวลาที่ตั้งกระทู้ ฯลฯ แล้วแต่จะหยิบนำอะไรมาแสดง ไม่เรียงลำดับ ไม่ใช่กระทู้ปักหมุด แต่เป็นกระทู้แนะนำ (ตามภาพ)

คล้ายๆ กระทู้ล่าสุด แต่การเลือกกระทู้มาแสดงเกิดจากการเลือก ไม่ใช่เลือกกระทู้ล่าสุดมาแสดง ข้อดีคือจะสามารถขุดเอากระทู้เก่าๆ แต่ยังมีประโชยน์และอยากให้โชว์อยู่ขึ้นมาแสดงในหน้าแรกได้

มาดูการนำไปใช้งานเลยดีกว่านะครับ

ไฟล์ที่เกี่ยวข้องมี 3 ไฟล์ และ 1 ใน 3 ไฟล์นั้นต้องสร้างขึ้นมาใหม่
1. Display.template.php // เพิ่มปุ่มโหวต หรือปุ่มเลือกกระทู้ในไฟล์นี้
2. BoardIndex.template.php //  สำหรับแสดงกระทู้โหวต และ
3. voterec.php // สำหรับโหวตหรือเลือกกระทู้

ไฟล์  Display.template.php ค้นหาคำว่า
if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id'])
echo '
<div class="approve_post">
', $txt['post_awaiting_approval'], '
</div>';

 พบแล้ววางคำสั่งด้านล่างนี้ต่อท้ายไป                              
      if(empty($message['counter']))
      echo '
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.js"></script>
<script type="text/javascript">
function voterec(id, ele){
   $(ele).unbind("click")
   $(".whs-rec-desc").html("โปรดรอ...")
   $.get("',$settings['theme_url'],'/voterec?act=vote&id="+id, {}, function(d){
      if(d!="OK")
         $(".whs-rec-desc").html(d)
      else
         $(".whs-rec-desc").html("โหวตเรียบร้อยแล้วครับ :)")
   })
}
</script>
                  <div class="whs-rec" style="float: right; text-align: center; font-size: 9pt;">
                     <a href="javascript:ubuntuclub();" onclick="voterec(',$context['current_topic'],', this); return false;">
                        <img src="',$settings['default_theme_url'],'/images/recommend.png" />
                     </a>
                     <div class="whs-rec-desc" style="margin-top: -20px;">
                        โหวตกระทู้นี้ ห้เป็นกระทู้แนะนำ
                     </div>
                  </div>';
               
ไฟล์ BoardIndex.template.php ให้ค้นหาคำว่า
/* Each category in categories is made up of:
id, href, link, name, is_collapsed (is it collapsed?), can_collapse (is it okay if it is?),
new (is it new?), collapse_href (href to collapse/expand), collapse_image (up/down image),
and boards. (see below.) */
 
    พบแล้วให้วางโค๊ดด้านล่างนี้ด้านบน ..
 
       // WHS's Mod -> Recommend Topic
   print <<<WHSDOC
   <div class="tborder marginbottom categoryframe">
      <h3 class="catbg headerpadding">กระทู้แนะนำ</h3>
      <table cellspacing="1" class="bordercolor boardsframe">
         <tr>
            <td class="windowbg icon"><img src="{$settings['default_theme_url']}/images/recommend.png" alt="กระทู้แนะนำ" border="0" /><div style="margin-top: -20px;">กระทู้แนะนำ</div></td>
            <td class="windowbg"><iframe src="/voterec?act=view" style="width:100%; border: none;"></iframe></td>
         </tr>
      </table>
   </div>
WHSDOC;          

และสุดท้ายสร้างสร้างไฟล์ voterec.php และวางชุดคำสั่งนี้ลงไป

<?php
include "smf/SSI.php";
// no trespasser!
if($context['user']['is_guest']){
   die('ต้องสมัครสมาชิกก่อนทำการโหวตครับ');
}
function boardName($bid){
   global $smcFunc;
   $req = $smcFunc['db_query']('', "
      SELECT name
      FROM {db_prefix}boards
      WHERE id_board = {int:bid}
      LIMIT 1
   ", array(
      'bid' => $bid,
   ));
   $row = $smcFunc['db_fetch_row']($req);
   return $row[0];
}
// yeah, I cheat.
// this using the [t=..] by the DtTvB :) ported to SMF 2's
// Get topic title from Zone-IT, with member color link!
function ubuntuclub_topic($message){
   global $smcFunc, $memberContext, $txt, $scripturl;
   $req = $smcFunc['db_query']('', "
      SELECT subject, id_member, id_board, id_topic
      FROM {db_prefix}messages
      WHERE id_topic = {int:idt}
      ORDER BY id_msg ASC LIMIT 1
   ", array(
      'idt' => $message,
   ));
   $row = $smcFunc['db_fetch_row']($req);
   if($row[1] != 0){
      // I don't reinvent the wheel, I'm lazy. I know this is slow but since we use iframe that doesn't matter.
      loadMemberData($row[1], false, 'minimal');
      @loadMemberContext($row[1]); // SHUT UP!
      $member = $memberContext[$row[1]]['link'];
   }else{
      $member = $txt['guest_title']; //I'm Fedora's l10n team after all.
   }
   // get the board's name!
   $bn = boardName($row[2]);
   return array($row[0], $member, "<a href='{$scripturl}/board,{$row[2]}.0.html'>$bn</a>");
}
if($_GET['act'] == "vote"){
   $topic = $_GET['id'];
   // is that thing really, exists?
   if (!ubuntuclub_topic($topic)){
      $smcFunc['db_free_result']($request);
      die("ไม่พบกระทู้ที่เรียก");
   }
   $smcFunc['db_free_result']($request);
   // well, so now it's exists. Just inject that into the table
   // but we need to know how much vote does it having?
   $request = $smcFunc['db_query']('', '
      SELECT * FROM {db_prefix}recommend WHERE ID_TOPIC = {int:idt}
   ', array(
      'idt' => $topic
   ));
   // hmm, PHP's DBAPI is clearly a mess, python's DBAPI is really simple
   $recommend = $smcFunc['db_fetch_row']($request);
   $smcFunc['db_free_result']($request);
   if(!$recommend){
      $request = $smcFunc['db_query']('', '
         INSERT INTO {db_prefix}recommend VALUES ({int:idt}, 1, "'.$context['user']['id'].'")
      ', array(
         'idt' => $topic
      ));
      die("OK");
   }else{
      // PHP showing it's suckness again, I think context.user.id in recommend[2].split(",") is more readable
      if(in_array($context['user']['id'], split(",", $recommend[2]))){
         die("คุณโหวตไปแล้ว");
      }
      $recommend[2] .= ",".$context['user']['id'];
      $recommend[1] += 1;
      // commit!
      $request = $smcFunc['db_query']('', '
         UPDATE {db_prefix}recommend SET count = {int:count}, voters = "'.$recommend[2].'"
         WHERE ID_TOPIC = {int:idt}
      ', array(
         'idt' => $topic,
         'count' => $recommend[1]
      ));
      die("OK");
   }
}else if($_GET['act'] == "view"){
   $req = $smcFunc['db_query']('', "
      SELECT ID_TOPIC FROM {db_prefix}recommend
      ORDER BY count DESC LIMIT 5
   ", array());
   while($row = $smcFunc['db_fetch_row']($req)){
      $tt = ubuntuclub_topic($row[0]);
      // hard coding to prevent beggars to use this
      print "<div><a href='$scripturl/topic,{$row[0]}.0.html' target='_parent'>{$tt[0]}</a> {$txt['started_by']} {$tt[1]} {$txt['in']} {$tt[2]}</div>";
   }
}
 
เซฟไว้ในโฟล์เดอร์ธีมของเรา
สุดท้ายต้องไปสร้างตารางไว้ในฐานข้อมูลด้วยครัับ

CREATE TABLE `smf_recommend` (
  `ID_TOPIC` int(11) NOT NULL,
  `count` int(11) NOT NULL default '0',
  `voters` longtext NOT NULL,
  PRIMARY KEY  (`ID_TOPIC`),
  KEY `count` (`count`)
)

ทั้งหมดนี้ผมเอาโค๊ดจากลิงค์ที่อ้างอิงด้านบนมา โดยไม่ได้ปรับแต่งหรือแก้ไขแต่อย่างใด ทั้งนี้เพื่อให้เครดิตแก่ผู้เขียนครับ
แต่ถ้าจะเอาไปใช้งานจริงก็ลองปรับดูให้เข้ากับบอร์ดของเรา จะให้สมาชิกสามารถโหวตได้ด้วย หรือให้เฉพาะแอดมินเท่านั้นโหวตก็ไปลองปรับกันใช้ดูครับ