Author Topic: วิธีเพิ่มความยาวตัวอักษรของหัวข้อกระทู้ smf 2.x ขึ้นไป  (Read 5088 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
วิธีเพิ่มความยาวตัวอักษรของหัวข้อกระทู้

โดยปรกติหัวข้อกระทู้จะตั้งได้ยาว 80 ตัวอักษรภาษาอังกฤษ แต่ถ้าเป็นภาษาไทยจะได้ไม่ถึง 80 ตัวอักษรจริงๆ
ทำให้อาจน้อยเกินไปจนไม่ค่อยสื่อความหมายสำหรับภาษาไทย เรามีวิธีเพิ่มความยาวตัวอักษรของหัวข้อกระทู้ดังนี้

แก้ไขไฟล์ Post.template.php ที่อยู่ใน Themes/default/Post.template.php

// Now show the subject box for this post.
   echo '
      <dt>
         <span', isset($context['post_error']['no_subject']) ? ' class="error"' : '', ' id="caption_subject">', $txt['subject'], ':</span>
      </dt>
      <dd>
         <input type="text" name="subject"', $context['subject'] == '' ? '' : ' value="' . $context['subject'] . '"', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" class="input_text" />
      </dd>
      <dt class="clear_left">
         ', $txt['message_icon'], ':
      </dt>
      <dd>

ลองแก้ maxlength จาก 80 เป็น 200 ดูนะครับ

// Now show the subject box for this post.
   echo '
      <dt>
         <span', isset($context['post_error']['no_subject']) ? ' class="error"' : '', ' id="caption_subject">', $txt['subject'], ':</span>
      </dt>
      <dd>
         <input type="text" name="subject"', $context['subject'] == '' ? '' : ' value="' . $context['subject'] . '"', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="200" class="input_text" />
      </dd>
      <dt class="clear_left">
         ', $txt['message_icon'], ':
      </dt>
      <dd>

บางคนทำแค่นี้ก็ใช้ได้ (อาจเป็น Version อื่น) แต่ของผมต้องแก้อีกไฟล์นึงครับที่ไฟล์ Post.php ที่อยู่ใน Sources/Post.php อีก 2 ที่คือ

// Make sure the subject isn't too long - taking into account special characters.
if ($smcFunc['strlen']($form_subject) > 100)
   $form_subject = $smcFunc['substr']($form_subject, 0, 100);

และ

// At this point, we want to make sure the subject isn't too long.
if ($smcFunc['strlen']($_POST['subject']) > 100)
   $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);


แก้จาก 100 เป็น 200 ครับ

// Make sure the subject isn't too long - taking into account special characters.
if ($smcFunc['strlen']($form_subject) > 200)
   $form_subject = $smcFunc['substr']($form_subject, 0, 200);

และ

// At this point, we want to make sure the subject isn't too long.
if ($smcFunc['strlen']($_POST['subject']) > 200)
   $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 200);


แก้ได้มากที่สุดคือ 255 นะครับ

เครดิตจาก
How to increase the Subject length
http://www.simplemachines.org/community/index.php?topic=359405.0
http://itamusing.com/smf/index.php?topic=14.0