ผู้เขียน หัวข้อ: Rewrite SMF 2.0.2 ทำ URL ให้เป็นภาษาไทย  (อ่าน 3056 ครั้ง)

0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

ออฟไลน์ Admin

  • Administrator
  • *****
  • กระทู้: 1415
  • Level:
    0%
  • Thank : 61
  • เพศ: ชาย
    • ดูรายละเอียด
    • สะกิดข่าว
Rewrite SMF 2.0.2 ทำ URL ให้เป็นภาษาไทย
« เมื่อ: ตุลาคม 13, 2012, 11:29:58 pm »
1. Login เข้าผู้ดูแลระบบ แล้วไปที่ ส่วนปรับแต่งค่าการใช้งาน>ติ๊กที่ แสดง URLs โดยปราศจาก ?'s Apache เท่านั้น!
    Admin Login > Edit Features and Options ->  Show URL's without ?'s

2. Open fire เปิดไฟล์ ./Source/MessageIndex.php

Find : ค้นหา

โค๊ด: [Select]
'time' => timeformat($row['first_poster_time']),
'timestamp' => forum_time(true, $row['first_poster_time']),
'subject' => $row['first_subject'],
'preview' => $row['first_body'],
'icon' => $row['first_icon'],
'icon_url' => $settings[$context['icon_sources'][$row['first_icon']]] . '/post/' . $row['first_icon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['first_subject'] . '</a>'



Replace With : แทนที่ด้วย

โค๊ด: [Select]
'time' => timeformat($row['first_poster_time']),
'timestamp' => forum_time(true, $row['first_poster_time']),
'subject' => $row['first_subject'],
'preview' => $row['first_body'],
'icon' => $row['first_icon'],
'icon_url' => $settings[$context['icon_sources'][$row['first_icon']]] . '/post/' . $row['first_icon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
$keyword= preg_replace("~[\s]+~","-",$row['first_subject']),
$keyword = urlencode(preg_replace('~[^a-z0-9ก-๙\.\-\_]~iu','',$keyword)),
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0/' . str_replace(" ","-",$row['first_subject']) . '" target="_blank">' . $row['first_subject'] . '</a>'
/*'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0[color=red][b]/' . urlencode(preg_replace('~[^a-z0-9ก-๙\.\-\_]~iu','',$keyword)) . '[/b][/color]">' . $row['first_subject'] . '</a>'*/
/*'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0/' . urlencode($keyword) . '" target="_blank">' . $row['first_subject'] . '</a>'*/

3. Save as เป็น UTF-8

 
แชร์บทความ...
โค้ดแบบ forum
(BBCode)
โค้ดแบบ site/blog
(HTML)