หมวดไฟฟ้า/อิเล็กทรอนิกส์/คอมพิวเตอร์ => Programming => ห้องคอมพิวเตอร์ => ห้อง SMF 2.0.X => ข้อความที่เริ่มโดย: Auto Man ที่ 20 เมษายน 2559, 07:31:08

หัวข้อ: ทำกระทู้เมื่อเร็วๆ นี้ให้เป็นตารางและเพิ่ม Replies & View icon New ลงใน SMF2.0.5
เริ่มหัวข้อโดย: Auto Man ที่ 20 เมษายน 2559, 07:31:08
ทำกระทู้เมื่อเร็วๆ นี้ให้เป็นตารางและเพิ่ม Replies & View อ่าน/ตอบ icon New ลงใน SMF2.0.5
ปกติ SMF2.0x จะไม่มีตารางและ Replies & Views อ่าน/ตอบ และ icon New  แสดง ในหน้าแรกของกระทู้เมื่อเร็วๆนี้ (Recent Post) แต่เราสามารถเพิ่มคุณสมบัตินี้เองได้ มาดูวิธีทำ

ตรงนี้มีภาพ! แต่ท่านจะมองไม่เห็น , ท่านต้อง  สมัครสมาชิก หรือ ลงชื่อเข้าระบบ


ตรงนี้มีภาพ! แต่ท่านจะมองไม่เห็น , ท่านต้อง  สมัครสมาชิก หรือ ลงชื่อเข้าระบบ
หัวข้อ: ทำกระทู้เมื่อเร็วๆ นี้ให้เป็นตารางและเพิ่ม Replies & View icon New ลงใน SMF2.0.5
เริ่มหัวข้อโดย: Auto Man ที่ 20 เมษายน 2559, 07:32:01
มีแหล่งที่มาอยู่สองที่ ลองติดตามดู

http://www.banpongpond-src.com/smf/index.php?topic=605.0

อีกที่

http://www.welovethailand.com/webboard/index.php

 :-X
หัวข้อ: ทำกระทู้เมื่อเร็วๆ นี้ให้เป็นตารางและเพิ่ม Replies & View icon New ลงใน SMF2.0.5
เริ่มหัวข้อโดย: Auto Man ที่ 20 เมษายน 2559, 07:33:10
ว่างๆ จะจัดการบอร์ดเรา ...

  ไม่รู้จะเวิร์คกับ smf 2.0.11 มั๊ยเนี่ย...
หัวข้อ: ทำกระทู้เมื่อเร็วๆ นี้ให้เป็นตารางและเพิ่ม Replies & View icon New ลงใน SMF2.0.5
เริ่มหัวข้อโดย: Auto Man ที่ 20 เมษายน 2559, 16:30:48
   เคยลองทำมาแล้ว แต่ไม่สำเร็จ เนื่องจากค้นหาในไฟล์ที่กำหนด บางทีไม่มีโค๊ดที่ว่า
เลยไม่รู้จะไปต่อยังไง...

   เลยใช้มอดทำได้อย่างที่เห็นในบอร์ดนี่แหละ ใส่ตารางหรือตกแต่งยังไม่ได้
หัวข้อ: ทำกระทู้เมื่อเร็วๆ นี้ให้เป็นตารางและเพิ่ม Replies & View icon New ลงใน SMF2.0.5
เริ่มหัวข้อโดย: Auto Man ที่ 20 เมษายน 2559, 16:32:32
แก้ไขไฟล์ ./Sources/Subs-Recent.php
Find: ค้นหา

โค๊ด: [Select]
IFNULL(mem.real_name, m.poster_name) AS poster_name, t.id_board, b.name AS board_name,
Replace With: ทับของเดิมที่หา

โค๊ด: [Select]
         IFNULL(mem.real_name, m.poster_name) AS poster_name, t.id_board, b.name AS board_name, t.num_views, t.num_replies,
Find: ค้นหา
โค๊ด: [Select]
'subject' => $row['subject'],
Add After : เติมต่อท้ายที่หา

โค๊ด: [Select]
         'views' => comma_format($row['num_views']),
         'replies' => comma_format($row['num_replies']),
หัวข้อ: ทำกระทู้เมื่อเร็วๆ นี้ให้เป็นตารางและเพิ่ม Replies & View icon New ลงใน SMF2.0.5
เริ่มหัวข้อโดย: Auto Man ที่ 20 เมษายน 2559, 16:36:51
แก้ไขไฟล์ Themes/default ธีมที่ใช้/BoardIndex.template.php

ค้นหา
โค๊ด: [Select]
// Show lots of posts.
      elseif (!empty($context['latest_posts']))
      {
         echo '
            <dl id="ic_recentposts" class="middletext">';

         /* Each post in latest_posts has:
               board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
               subject, short_subject (shortened with...), time, link, and href. */
         foreach ($context['latest_posts'] as $post)
            echo '
               <dt><strong>', $post['link'], '</strong> ', $txt['by'], ' ', $post['poster']['link'], ' (', $post['board']['link'], ')</dt>
               <dd>', $post['time'], '</dd>';
         echo '
            </dl>';

Replace With: ทับของเดิมที่หา
โค๊ด: [Select]
// Show lots of posts.
      elseif (!empty($context['latest_posts']))
      {
         echo '
      <table cellpadding="0" cellspacing="1" width="100%" border="0">
           <tr>
               <td class="catbg2" style="text-align:left;" colspan="2">',$txt['recent_title'],'</td>
               <td class="catbg2" style="text-align:center;">',$txt['recent_views'],'</td>
               <td class="catbg2" style="text-align:center;">',$txt['recent_replies'],'</td>
               <td class="catbg2" style="text-align:center;">',$txt['recent_boardname'],'</td>
               <td class="catbg2" style="text-align:center;">',$txt['recent_by'],'</td>
               <td class="catbg2" style="text-align:right;">',$txt['recent_time'],'</td>
             </tr>';

                  $cnt = 0;
         foreach ($context['latest_posts'] as $post){
         $cnt++;
         $class = ($cnt % 2) ? 'windowbg' : 'windowbg2';
         
        echo '
                     <tr>
                     <td></td>
                        <td class="', $class, '" title="', $post['preview'] ,'">', $post['link'], ' <img src="' . $settings['lang_images_url'] . '/new.gif"</td>
                        <td class="', $class, '" style="text-align:center;">', $post['views'], '</td>   
                        <td class="', $class, '" style="text-align:center;">', $post['replies'], '</td>                     
                        <td class="', $class, '" style="text-align:center;">',$post['board']['link'], '</td>
                        <td class="', $class, '" style="text-align:center;">',$post['poster']['link'], '</td>
                        <td class="', $class, '" style="text-align:right;" nowrap="nowrap">', $post['time'], '</td>

                     </tr>';
       }

         echo '
            </table>';

* พวกคลาส <td class="catbg2" และ <td class="', $class, '" เราสามารถเปลี่ยนและตกแต่งรูปแบบให้เป็นของเราได้ตามใจชอบแต่ถ้าไม่เปลี่ยนก็จะใช้ค่าของ default หรือธีมปัจจุบันของเราโดยอัตโนมัติ
หัวข้อ: ทำกระทู้เมื่อเร็วๆ นี้ให้เป็นตารางและเพิ่ม Replies & View icon New ลงใน SMF2.0.5
เริ่มหัวข้อโดย: Auto Man ที่ 20 เมษายน 2559, 16:38:05
แก้ภาษาไทย /Themes/default/languages/Modifications.thai-utf8.php
ค้นหา

โค๊ด: [Select]
?>
วางก่อนที่หา
โค๊ด: [Select]
//welove  Replies and Views on Recent Posts
$txt['recent_title'] = 'กระทู้ล่าสุด';
$txt['recent_views'] = 'อ่าน';
$txt['recent_replies'] = 'ตอบ';
$txt['recent_boardname'] = 'รายชื่อบอร์ด';
$txt['recent_by'] = 'ผู้โพสท์';
$txt['recent_time'] = 'วัน/เวลา';

*** อัพไฟล์รูป   ไปใส่ที่ Themes/default ธีมที่ใช้/images/english/new.gif
    Themes/default ธีมที่ใช้/images/thai-utf8/new.gif

จบ....โชคดีครับ

 ขอบคุณ  ที่มา :  http://www.welovethailand.com/webboard/index.php
หัวข้อ: ทำกระทู้เมื่อเร็วๆ นี้ให้เป็นตารางและเพิ่ม Replies & View icon New ลงใน SMF2.0.5
เริ่มหัวข้อโดย: Auto Man ที่ 20 เมษายน 2559, 16:58:35
มาดูไฟล์แรกที่จะต้องแก้ไขกันใน smf 2.0.11 เป็นเช่นไร
ไฟล์ ./Sources/Subs-Recent.php

โค๊ด: [Select]
IFNULL(mem.real_name, m.poster_name) AS poster_name,
SUBSTRING(m.body, 1, 384) AS body, m.smileys_enabled
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_last_msg)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member})
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:current_member})' : '') . '
WHERE t.id_last_msg >= {int:min_message_id}
AND ' . $user_info['query_wanna_see_board'] . ($modSettings['postmod_active'] ? '
AND t.approved = {int:is_approved}
AND m.approved = {int:is_approved}' : '') . '
ORDER BY t.id_last_msg DESC
LIMIT ' . $latestPostOptions['number_posts'],
array(
'current_member' => $user_info['id'],
'min_message_id' => $modSettings['maxMsgID'] - 35 * min($latestPostOptions['number_posts'], 5),
'is_approved' => 1,
)
);
$posts = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
// Censor the subject and post for the preview ;).
censorText($row['subject']);
censorText($row['body']);

$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br />' => '&#10;')));
if ($smcFunc['strlen']($row['body']) > 128)
$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';

// Build the array.
$posts[] = array(
'board' => array(
'id' => $row['id_board'],
'name' => $row['board_name'],
'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['board_name'] . '</a>'
),
'topic' => $row['id_topic'],
'poster' => array(
'id' => $row['id_member'],
'name' => $row['poster_name'],
'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 24),
'preview' => $row['body'],
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true, $row['poster_time']),
'raw_timestamp' => $row['poster_time'],
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#msg' . $row['id_msg'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#msg' . $row['id_msg'] . '" rel="nofollow">' . $row['subject'] . '</a>'
);
}
$smcFunc['db_free_result']($request);

return $posts;
}

ลองไล่ดู งงครับ การเขียนโค๊ดไม่เหมือนกัน จะแทนที่ก็ไม่ได้ล่ะทีนี้
หัวข้อ: ทำกระทู้เมื่อเร็วๆ นี้ให้เป็นตารางและเพิ่ม Replies & View icon New ลงใน SMF2.0.5
เริ่มหัวข้อโดย: Auto Man ที่ 20 เมษายน 2559, 16:59:51
มาดูที่ไฟล์ boardindex.template.php กันใน smf 2.0.11

โค๊ด: [Select]
// Show lots of posts.
elseif (!empty($context['latest_posts']))
{
echo '
<dl id="ic_recentposts" class="middletext">';

/* Each post in latest_posts has:
board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
subject, short_subject (shortened with...), time, link, and href. */
foreach ($context['latest_posts'] as $post)
echo '
<dt><strong>', $post['link'], '</strong> ', $txt['by'], ' ', $post['poster']['link'], ' (', $post['board']['link'], ')</dt>
<dd>', $post['time'], '</dd>';
echo '
</dl>';
}
echo '
</div>';
}

   ไฟล์ตัวนี้ใกล้เคียงหน่อย พอแก้ไขได้
หัวข้อ: ทำกระทู้เมื่อเร็วๆ นี้ให้เป็นตารางและเพิ่ม Replies & View icon New ลงใน SMF2.0.5
เริ่มหัวข้อโดย: Auto Man ที่ 20 เมษายน 2559, 17:07:17
มาดูไฟล์สุดท้ายกันบ้างที่ต้องแก้ไขใน smf 2.0.11
/Themes/default/languages/Modifications.thai-utf8.php

โค๊ด: [Select]
<?php
// Version: 2.0; Modifications


// Text for the Recent Topics On "Recent Posts" Page Mod.
$txt['RecentTopicsOnRecentPostsPage_mode'] = 'Recent Topics On "Recent Posts" Page mode';
$txt['RecentTopicsOnRecentPostsPage_new'] = 'Recent/New Topics';
$txt['RecentTopicsOnRecentPostsPage_updated'] = 'กระทู้เมื่อเร็วๆ นี้';
$txt['RecentTopicsOnRecentPostsPage_actiontitle'] = 'Recent Topics';
$txt['RecentTopicsOnRecentPostsPage_updated_actiontitle'] = 'กระทู้เมื่อเร็วๆ นี้';
$txt['RecentTopicsOnRecentPostsPage_linktext'] = 'View the most recent topics on the forum.';
$txt['RecentTopicsOnRecentPostsPage_updated_linktext2'] = 'View the most recently updated topics on the forum.';
// Text for the Recent Topics On Board Index.
$txt['RecentTopicsOnBoardIndex_recenttopics'] = 'กระทู้เมื่อเร็วๆนี้';
?>
หัวข้อ: ทำกระทู้เมื่อเร็วๆ นี้ให้เป็นตารางและเพิ่ม Replies & View icon New ลงใน SMF2.0.5
เริ่มหัวข้อโดย: Auto Man ที่ 20 เมษายน 2559, 17:21:58
ใครอยากจะโหลดไฟล์ smf 2.0.5 ลองดูที่ไฟล์แนบ
หัวข้อ: ทำกระทู้เมื่อเร็วๆ นี้ให้เป็นตารางและเพิ่ม Replies & View icon New ลงใน SMF2.0.5
เริ่มหัวข้อโดย: Auto Man ที่ 21 เมษายน 2559, 16:10:52
ลองไล่ไฟล์ทั้งสามของ smf 2.0.5 กับ smf 2.0.11 มีบางส่วนที่แตกต่างกัน
โดยเฉพาะในไฟล์ sub recent.php เลยตัดต่อพันธุกรรม ผลออกมาเป็นเช่นไร
ไปดูภาพกัน

ตรงนี้มีภาพ! แต่ท่านจะมองไม่เห็น , ท่านต้อง  สมัครสมาชิก หรือ ลงชื่อเข้าระบบ
 (http://upic.me/show/58330946)

ออกมาใกล้เคียงกับที่ต้องการ แต่ว่าต้องไปปรับแต่งอีกสักเล็กสักน้อย พวกตัวหนังสือจะใหญ่เกินไป
ีมีหัวข้อตอบกลับซ้ำกัน ต้องปรับอีก
หัวข้อ: ทำกระทู้เมื่อเร็วๆ นี้ให้เป็นตารางและเพิ่ม Replies & View icon New ลงใน SMF2.0.5
เริ่มหัวข้อโดย: Auto Man ที่ 21 เมษายน 2559, 16:16:03
  ลองดูไฟล์ smf 2.0.11 ที่ตัดต่อพันธุกรรมแล้ว  ดูที่ไฟล์แนบ
หัวข้อ: ทำกระทู้เมื่อเร็วๆ นี้ให้เป็นตารางและเพิ่ม Replies & View icon New ลงใน SMF2.0.5
เริ่มหัวข้อโดย: Auto Man ที่ 21 เมษายน 2559, 16:17:49
ส่วนไฟล์เดิมของบอร์ด www.auto-nkp.com ที่ปรับแต่งแล้ว
ก่อนหน้าที่จะทำการตัดแต่งครับ ที่ไฟล์แนบ 3 ไฟล์

หน้าตาเดิมประมาณนี้

ตรงนี้มีภาพ! แต่ท่านจะมองไม่เห็น , ท่านต้อง  สมัครสมาชิก หรือ ลงชื่อเข้าระบบ
 (http://upic.me/show/58331028)