collapse

ผู้เขียน หัวข้อ: การจัดเรียง "กระทู้เมื่อเร็วๆ นี้" ให้ดูสวยงาม  (อ่าน 2385 ครั้ง)

ออฟไลน์ LittleCat

  • มิตรนักธรรม

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



ดูแล้วเบียดเสียดกันไปข้างนึง ไม่สวยงามเลย
สามารถแก้ให้ดูสวยงามเรียบร้อยได้ โดย
เปิดไฟล์ 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>';

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



ออฟไลน์ LittleCat

  • มิตรนักธรรม

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






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



ต้นฉบับ





ตัวอย่าง 1





ตัวอย่าง 2





ตัวอย่าง 3






ตัวอย่าง 4






เป็นต้น

Tags: