Home Webboard ArticlesKnowledges  
ข่าวประกาศ:

:: กติกา มารยาท ในการใช้งานเว็บบอร์ด ::
กรุณากรอกอีเมล์จริงในการสมัคร และรับอีเมล์ยืนยันเพื่อใช้งานในบอร์ด

ผู้เขียน หัวข้อ: ปรับแต่งส่วน RecentPost กระทู้ล่าสุดแนว Zone-My สวยงามเต็มรูปแบบ 2.0.x เท่านั้น  (อ่าน 4050 ครั้ง)

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

ออฟไลน์ Zone-My

  • Just Mem
  • ****
  • กระทู้: 60
  • เห็นด้วย&ขอบคุณ: 17
  • เพศ: ชาย
รูปตัวอย่าง


ขั้นแรกลง Mod นี้ก่อน จะทำให้แสดงเวลาเป็น วินาที นาที เเละชั่วโมง สีสันสวยงาม
http://custom.simplemachines.org/mods/index.php?mod=2432

แก้ไขเพิ่มเติม
เปิดไฟล์ ./Sources/Subs.php
ค้นหา
โค๊ด: [Select]
if ($then['yday'] == $now['yday'] && $then['year'] == $now['year'])
{
// SMF has room for relative dates, no?
if ($modSettings['todayMod'] == 3 && (empty($modSettings['enable_rt_xml']) && !isset($_REQUEST['xml']) || !empty($modSettings['enable_rt_xml']) && !isset($_REQUEST['xml'])))
{
// Determine the relative dates
$seconds = $nowtime - $time;
$minutes = floor($seconds / 60);
$hours = floor($minutes / 60);

// Numbers need language strings, too
if ($seconds > -1)
{
if ($hours > 0 && $minutes > 59)
$retVal = $hours . ' ' . ($hours == 1 ? $txt['hour'] : $txt['hours']) . '  ' . $txt['ago'];
elseif ($minutes > 0 && $seconds > 59)
$retVal = $minutes . ' ' . ($minutes == 1 ? $txt['minute'] : $txt['minutes']) . '  ' . $txt['ago'];
else
$retVal = $seconds . ' ' . ($seconds == 1 ? $txt['second'] : $txt['seconds']) . '  ' . $txt['ago'];
}
// Time is in the future so rework :P
else
{
$seconds = $time - $nowtime;
$minutes = floor($seconds / 60);
$hours = floor($minutes / 60);
if ($hours > 0 && $minutes > 59)
$retVal = $txt['in'] . '  ' . $hours . ' ' . ($hours == 1 ? $txt['hour'] : $txt['hours']);
elseif ($minutes > 0 && $seconds > 59)
$retVal = $txt['in'] . '  ' . $minutes . ' ' . ($minutes == 1 ? $txt['minute'] : $txt['minutes']);
else
$retVal = $txt['in'] . '  ' . $seconds . ' ' . ($seconds == 1 ? $txt['second'] : $txt['seconds']);
}
}
// Defaults FTW!
else
$retVal = $txt['today'] . timeformat($log_time, $today_fmt, $offset_type);

return $retVal;
}

แก้เป็น
โค๊ด: [Select]
if ($then['yday'] == $now['yday'] && $then['year'] == $now['year'])
{
// SMF has room for relative dates, no?
if ($modSettings['todayMod'] == 3 && (empty($modSettings['enable_rt_xml']) && !isset($_REQUEST['xml']) || !empty($modSettings['enable_rt_xml']) && !isset($_REQUEST['xml'])))
{
// Determine the relative dates
$seconds = $nowtime - $time;
$minutes = floor($seconds / 60);
$hours = floor($minutes / 60);

// Numbers need language strings, too
if ($seconds > -1)
{
if ($hours > 0 && $minutes > 59)
$retVal = '<font color=#AEB400> ' . $hours . ' ' . ($hours == 1 ? $txt['hour'] : $txt['hours']) . ' ' . $txt['ago'] . '</font>';
elseif ($minutes > 0 && $seconds > 59)
$retVal = '<span style="color:#C68A00;font-size:1.22em"><b> ' . $minutes . ' ' . ($minutes == 1 ? $txt['minute'] : $txt['minutes']) . '  ' . $txt['ago'] . '</b></span>';
else
$retVal = '<span style="color:#EF2700;font-size:1.39em"><b> ' . $seconds . ' ' . ($seconds == 1 ? $txt['second'] : $txt['seconds']) . '  ' . $txt['ago'] . '</b></span>';
}
// Time is in the future so rework :P
else
{
$seconds = $time - $nowtime;
$minutes = floor($seconds / 60);
$hours = floor($minutes / 60);
if ($hours > 0 && $minutes > 59)
$retVal = $txt['in'] . '  ' . $hours . ' ' . ($hours == 1 ? $txt['hour'] : $txt['hours']);
elseif ($minutes > 0 && $seconds > 59)
$retVal = $txt['in'] . '  ' . $minutes . ' ' . ($minutes == 1 ? $txt['minute'] : $txt['minutes']);
else
$retVal = $txt['in'] . '  ' . $seconds . ' ' . ($seconds == 1 ? $txt['second'] : $txt['seconds']);
}
}
// Defaults FTW!
else
$retVal = $txt['today'] . timeformat($log_time, $today_fmt, $offset_type) . ' ' . $txt['yesterday'] . ' ';

return $retVal;
}

เปิดไฟล์ ./Themes/default/languages/index.thai-utf8.php
เพิ่มโค้ด
โค๊ด: [Select]
$txt['hours'] = 'ชั่วโมง';
$txt['minutes'] = 'นาที';
$txt['seconds'] = 'วินาที';
$txt['hour'] = 'ชั่วโมงเเรก';
$txt['minute'] = 'นาทีเเรก';
$txt['second'] = 'วินาทีเเรก';
$txt['ago'] = 'เเล้ว';
$txt['in'] = 'ใน';
$txt['relative_today'] = 'Today with relative times';

เสร็จขั้นตอนแรกไปเเล้ว


แล้วลงม็อดนี้ จะทำให้ recent Topic ส่วน InfoCenter หรือ "ศูนย์กลางข้อมูล" ของเรานับจำนวนคนอ่าน-ตอบได้ครับ
เปิดไฟล์ ./Sources/Subs-Recent.php
ค้นหา
โค๊ด: [Select]
global $scripturl, $txt, $user_info, $modSettings, $smcFunc, $context;

// Find all the posts.  Newer ones will have higher IDs.  (assuming the last 20 * number are accessable...)
// !!!SLOW This query is now slow, NEEDS to be fixed.  Maybe break into two?
$request = $smcFunc['db_query']('substring', '
SELECT
m.poster_time, m.subject, m.id_topic, m.id_member, m.id_msg,
IFNULL(mem.real_name, m.poster_name) AS poster_name, t.id_board, b.name AS board_name,
SUBSTRING(m.body, 1, 385) AS body, m.smileys_enabled
FROM {db_prefix}messages AS m
INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
WHERE m.id_msg >= {int:likely_max_msg}' .
(!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
AND b.id_board != {int:recycle_board}' : '') . '
AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? '
AND t.approved = {int:is_approved}
AND m.approved = {int:is_approved}' : '') . '
ORDER BY m.id_msg DESC
LIMIT ' . $latestPostOptions['number_posts'],
array(
'likely_max_msg' => max(0, $modSettings['maxMsgID'] - 50 * $latestPostOptions['number_posts']),
'recycle_board' => $modSettings['recycle_board'],
'is_approved' => 1,
)
);

เเก้ไขเป็น
โค๊ด: [Select]
global $scripturl, $txt, $user_info, $modSettings, $smcFunc, $context;

// Find all the posts.  Newer ones will have higher IDs.  (assuming the last 20 * number are accessable...)
// !!!SLOW This query is now slow, NEEDS to be fixed.  Maybe break into two?
$request = $smcFunc['db_query']('substring', '
SELECT
m.poster_time, m.subject, m.id_topic, m.id_member, m.id_msg,
IFNULL(mem.real_name, m.poster_name) AS poster_name, t.id_board, b.name AS board_name, t.num_views, t.num_replies,
SUBSTRING(m.body, 1, 385) AS body, m.smileys_enabled
FROM {db_prefix}messages AS m
INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
WHERE m.id_msg >= {int:likely_max_msg}' .
(!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
AND b.id_board != {int:recycle_board}' : '') . '
AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? '
AND t.approved = {int:is_approved}
AND m.approved = {int:is_approved}' : '') . '
ORDER BY m.id_msg DESC
LIMIT ' . $latestPostOptions['number_posts'],
array(
'likely_max_msg' => max(0, $modSettings['maxMsgID'] - 50 * $latestPostOptions['number_posts']),
'recycle_board' => $modSettings['recycle_board'],
'is_approved' => 1,
)
);

ค้นหา
โค๊ด: [Select]
// 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>'
);

แก้เป็น
โค๊ด: [Select]
// 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']) ? (!empty($modSettings['MemberColorGuests']) ? '<span style="color:'.$modSettings['MemberColorGuests'].';">' : '').$row['poster_name'].(!empty($modSettings['MemberColorGuests']) ? '</span>' : '') : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" title="' . $txt['profile_of'] . ' ' . $row['poster_name'] . '">' . $row['poster_name'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 24),
'preview' => $row['body'],
'time' => timeformat($row['poster_time']),
'views' => comma_format($row['num_views']),
'replies' => comma_format($row['num_replies']),
'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>'
);

แก้แค่นี้พอนะครับ เรียบร้อยแล้ว


ต่อมาลงม็อดนี้เลย จะแสดงเป็นคอลัม recent post สวยงาม
http://custom.simplemachines.org/mods/index.php?mod=2469

เปิดไฟล์ ./Themes/default/BoardIndex.template.php
เเก้เพิ่มเติมดังนี้
ค้นหา
โค๊ด: [Select]
// This is the "Recent Posts" bar.
if (!empty($settings['number_recent_posts']) && (!empty($context['latest_posts']) || !empty($context['latest_post'])))
{
echo '
<div class="title_barIC">
<h4 class="titlebg">
<span class="ie6_header floatleft">
<a href="', $scripturl, '?action=recent"><img class="icon" src="', $settings['images_url'], '/post/xx.gif" alt="', $txt['recent_posts'], '" /></a>
', $txt['recent_posts'], '
</span>
</h4>
</div>
<div class="hslice" id="recent_posts_content">
<div class="entry-title" style="display: none;">', $context['forum_name_html_safe'], ' - ', $txt['recent_posts'], '</div>
<div class="entry-content" style="display: none;">
<a rel="feedurl" href="', $scripturl, '?action=.xml;type=webslice">', $txt['subscribe_webslice'], '</a>
</div>';

// Only show one post.
if ($settings['number_recent_posts'] == 1)
{
// latest_post has link, href, time, subject, short_subject (shortened with...), and topic. (its id.)
echo '
<strong><a href="', $scripturl, '?action=recent">', $txt['recent_posts'], '</a></strong>
<p id="infocenter_onepost" class="middletext">
', $txt['recent_view'], ' &quot;', $context['latest_post']['link'], '&quot; ', $txt['recent_updated'], ' (', $context['latest_post']['time'], ')<br />
</p>';
}

เเก้เป็น
โค๊ด: [Select]
// This is the "Recent Posts" bar.
if (!empty($settings['number_recent_posts']) && (!empty($context['latest_posts']) || !empty($context['latest_post'])))
{
echo '
<dl id="ic_recentposts" class="middletext">';
echo '
                                <h4>
<span class="ie6_header floatleft">
<a href="', $scripturl, '?action=recent" target="_blank"><img class="icon" src="http://image.ohozaa.com/i/88d/XEYnVs.png" alt="', $txt['recent_posts'], '" /></a>
<font size="4pt" color="#87CEFA">หัวข้อเมื่อเร็วๆนี้</font>
</span>
                                 </h4><br><br>
<div class="hslice" id="recent_posts_content">
<div class="entry-title" style="display: none;">', $context['forum_name_html_safe'], ' - ', $txt['recent_posts'], '</div>
<div class="entry-content" style="display: none;">
<a rel="feedurl" href="', $scripturl, '?action=.xml;type=webslice">', $txt['subscribe_webslice'], '</a>
</div>';

// Only show one post.
if ($settings['number_recent_posts'] == 1)
{
// latest_post has link, href, time, subject, short_subject (shortened with...), and topic. (its id.)
echo '
<strong><a href="', $scripturl, '?action=recent">', $txt['recent_posts'], '</a></strong>
<p id="infocenter_onepost" class="middletext">
', $txt['recent_view'], ' &quot;', $context['latest_post']['link'], '&quot; ', $txt['recent_updated'], ' (', $context['latest_post']['time'], ')<br />
</p>';
}

หลังจากที่ลงม็อดไปแล้วนั้นให้เเก้โค้ดต่อไปดังนี้
ค้นหา
โค๊ด: [Select]
//-- Labradoodle-360; Advanced Recent Posts
elseif (!empty($context['latest_posts']))
{
echo '
<table align="center" cellpadding="5" cellspacing="0" width="100%" border="0">
        <tr>
                        <td class="arp_header">', $txt['topic_name'] ,':</td>
                        <td class="arp_header">', $txt['poster_name'] ,':</td>
              <td class="arp_header">', $txt['board_name'] ,':</td>
                        <td class="arp_header">', $txt['post_time'] ,':</td>
                    </tr>';
            foreach ($context['latest_posts'] as $post)
                    {
          echo '
                        <tr>
        <td class="arppost arp_left">', $post['link'], '</td>
        <td class="arppost arp_rest">', $post['poster']['link'], '</td>
        <td class="arppost arp_rest">', $post['board']['link'], '</td>
        <td class="arppost arp_rest">', $post['time'], '</td>
      </tr>';
                    }
        echo '
</table>
                <br />
            ';
}
        // End Labradoodle-360; Advanced Recent Posts --//

แก้เป็น
โค๊ด: [Select]
//-- Labradoodle-360; Advanced Recent Posts
elseif (!empty($context['latest_posts']))
{
echo '
<table align="center" cellpadding="5" cellspacing="0" width="100%" border="0">
        ';
            foreach ($context['latest_posts'] as $post)
                    {
          echo '
                        <tr>
        <td class="arppost arp_left"><img src="http://image.ohozaa.com/i/771/y4RgWG.png" alt="ใหม่"><strong>', $post['link'], '</strong></td>
        <td class="arppost arp_rest">(อ่าน ', $post['views'], ' / ตอบ ', $post['replies'], ')</td>
                                                <td class="arppost arp_rest">', $post['poster']['link'], '</td>
        <td class="arppost arp_rest">(', $post['board']['link'], ')</td>
        <td class="arppost arp_rest">', $post['time'], '</td>
      </tr>';
                    }
        echo '
</table>
                <br />
            ';
}
        // End Labradoodle-360; Advanced Recent Posts --//

echo '
</div></div>';
}
                //end recent posts

เข้าไปแก้ในไฟล์ ./Themes/default/css/index.css
ค้นหา
โค๊ด: [Select]
/*-- Labradoodle-360; Advanced Recent Posts */
.arp_header {
font-weight: bold;
text-align: center;
}
.arppost {
background-color: #f6f6f6;
width: 20%;
text-align: center;
}
.arppost:hover {
background: #e0e6e6;
}
.arp_left {
border-top: 1px solid #b7b7b7;
border-bottom: 1px solid #b7b7b7;
border-left: 1px solid #b7b7b7;
border-right: 1px solid #b7b7b7;
}
.arp_rest {
border-top: 1px solid #b7b7b7;
border-bottom: 1px solid #b7b7b7;
border-right: 1px solid #b7b7b7;
}
/* End Labradoodle-360; Advanced Recent Posts --*/

แก้เป็น
โค๊ด: [Select]
/*-- Labradoodle-360; Advanced Recent Posts */
.arp_header {
font-size: 13px;
color: #0066CC;
font-weight: bold;
text-align: center;
border: 1px solid #B3E1FB;
background: #DBF1FD;
}
.arppost {
background-color: #f6f6f6;
text-align: center;
}
.arppost:hover {

background: #e0e6e6;
}
.arp_left {
background-color: #f6f6f6;
text-align:left;
padding-left:5px;
}
.arp_left:hover {
background: #e0e6e6;
}
.arp_rest {
/*border-top: 1px solid #B3E1FB;
border-bottom: 1px solid #B3E1FB;
border-right: 1px solid #B3E1FB;*/
}
.virep {color: #79B3C8}
/* End Labradoodle-360; Advanced Recent Posts --*/


เข้าไฟล์ภาษา Modification****.php ของเรา ในโฟลเดอร์ languages

ค้นหา
โค๊ด: [Select]
//-- Labradoodle-360; Advanced Recent Posts
$txt['topic_name'] = 'Topic';
$txt['poster_name'] = 'Poster';
$txt['board_name'] = 'Board';
$txt['post_time'] = 'Post Time';
// End Labradoodle-360; Advanced Recent Posts --//

แก้เป็น
โค๊ด: [Select]
//-- Labradoodle-360; Advanced Recent Posts
$txt['topic_name'] = 'หัวข้อเรื่อง';
$txt['view_replies'] = 'ความเคลื่อนไหว';
$txt['poster_name'] = 'เจ้าของโพสต์';
$txt['board_name'] = 'ห้อง';
$txt['post_time'] = 'วัน/เวลา';
// End Labradoodle-360; Advanced Recent Posts --//

หากอยากให้แสดงคอลัม recent post แบบนี้

เปิดไฟล์ ./Themes/default/BoardIndex.template.php
ค้นหา
โค๊ด: [Select]
elseif (!empty($context['latest_posts']))
{
echo '
<table align="center" cellpadding="5" cellspacing="0" width="100%" border="0">
        ';

แก้เป็น
โค๊ด: [Select]
elseif (!empty($context['latest_posts']))
{
echo '
<table align="center" cellpadding="5" cellspacing="0" width="100%" border="0">
        <tr>
                        <td class="arp_header">', $txt['topic_name'] ,'[แอท]</td>
                        <td class="arp_header">', $txt['view_replies'] ,'[แอท]</td>
                        <td class="arp_header">', $txt['poster_name'] ,'[แอท]</td>
              <td class="arp_header">', $txt['board_name'] ,'[แอท]</td>
                        <td class="arp_header">', $txt['post_time'] ,'[แอท]</td>
                    </tr>';

เรียบร้อยเเล้วครับ  :razz:

Credit: Zone-My.com
« แก้ไขครั้งสุดท้าย: 02, เมษายน 2013, 01:44:30 PM โดย Zone-My »


โซนมาย เเหล่งอาณาเขตออนไลน์ของคนไทย
------------------------------------------
zone-my.com :smitten:

ออฟไลน์ mars4d

  • Ju
  • *
  • กระทู้: 4
  • เห็นด้วย&ขอบคุณ: 0
 :grin:  ขอบคุณมากครับ  สวยงามๆๆ

ออฟไลน์ Piak Minburi

  • Just
  • **
  • กระทู้: 26
  • เห็นด้วย&ขอบคุณ: 16
  • เพศ: ชาย
    • GPStt.com Group

 

Sitemap 1 2 3 4 5 6 7 8 9 10 
Back to top