นักธรรม

ห้องสมุด "นักธรรม" => หมวด : เทคโนโลยี ไอที IT => ข้อความที่เริ่มโดย: LittleCat ที่ 22/03/2008, 13:12

หัวข้อ: การจัดเรียง "กระทู้เมื่อเร็วๆ นี้" ให้ดูสวยงาม
เริ่มหัวข้อโดย: LittleCat ที่ 22/03/2008, 13:12

จากเดิม หน้าแรก กระทู้เมื่อเร็วๆ นี้  จะเป็นเช่นนี้

(http://i56.photobucket.com/albums/g185/catzcatch/Board/board-16.jpg)

ดูแล้วเบียดเสียดกันไปข้างนึง ไม่สวยงามเลย
สามารถแก้ให้ดูสวยงามเรียบร้อยได้ โดย
เปิดไฟล์ Themes/default/BoardIndex.template.php ค้นหาส่วนนี้

โค๊ด: [Select]
// latest_post has link, href, time, subject, short_subject (shortened with...), and topic. (its id.)
echo '
<b><a href="', $scripturl, '?action=recent">', $txt[214], '</a></b>
<div class="smalltext">
', $txt[234], ' &quot;', $context['latest_post']['link'], '&quot; ', $txt[235], ' (', $context['latest_post']['time'], ')<br />
</div>';
}
// Show lots of posts.
            elseif (!empty($context['latest_posts']))
            {
            echo '
            <table width="100%" border="0">';
             /* 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 '
                         <tr>
                          <td valign="top">', $post['link'], ' ', $txt[525], ' ', $post['poster']['link'], '(', $post['board']['link'], ')</td>
                          <td align="right" valign="top" nowrap="nowrap">', $post['time'], '</td>
                          </tr>';
                  echo '
             </table>';

แล้วนำส่วนนี้เข้าไปแทนที่ ตั้งแต่ส่วน // Show lots of posts.

โค๊ด: [Select]
// Show lots of posts.
elseif (!empty($context['latest_posts']))
{
echo '
<table cellpadding="0" cellspacing="0" width="100%" border="0">';
/* 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 '
<tr>
<td align="right" valign="top" nowrap="nowrap">[', $post['board']['link'], ']</td>
                      <td valign="top">&nbsp;', $post['link'], ' ', $txt[525], ' ', $post['poster']['link'], '</td>
                      <td align="right" valign="top" nowrap="nowrap">', $post['time'], '</td>
</tr>';
echo '
</table>';

ก็จะได้ผลดังนี้

(http://i56.photobucket.com/albums/g185/catzcatch/Board/board-17.jpg)
หัวข้อ: Re: การจัดเรียง "กระทู้เมื่อเร็วๆ นี้" ให้ดูสวยงาม
เริ่มหัวข้อโดย: LittleCat ที่ 22/03/2008, 13:12

หรือจะทำการแก้ไขดัดแปลง ให้เป็นรูปแบบที่ตนเองชอบก็ได้ โดยการแก้ในส่วนนี้

(http://i56.photobucket.com/albums/g185/catzcatch/Board/board-18.jpg)


(http://i56.photobucket.com/albums/g185/catzcatch/Board/board-19.jpg)

ขอเพียงแค่ไม่ได้ลบสคริป php ก็จะไม่มีปัญหาอะไร (แก้ไขส่วนที่เป็นสีน้ำตาล)



ต้นฉบับ
(http://i56.photobucket.com/albums/g185/catzcatch/Board/board-24.jpg)

(http://i56.photobucket.com/albums/g185/catzcatch/Board/board-16.jpg)


ตัวอย่าง 1
(http://i56.photobucket.com/albums/g185/catzcatch/Board/board-25.jpg)

(http://i56.photobucket.com/albums/g185/catzcatch/Board/board-17.jpg)


ตัวอย่าง 2
(http://i56.photobucket.com/albums/g185/catzcatch/Board/board-20.jpg)

(http://i56.photobucket.com/albums/g185/catzcatch/Board/board-21.jpg)


ตัวอย่าง 3
(http://i56.photobucket.com/albums/g185/catzcatch/Board/board-22.jpg)

(http://i56.photobucket.com/albums/g185/catzcatch/Board/board-23.jpg)



ตัวอย่าง 4
(http://i56.photobucket.com/albums/g185/catzcatch/Board/board-26.jpg)

(http://i56.photobucket.com/albums/g185/catzcatch/Board/board-27.jpg)



เป็นต้น