ผู้เขียน หัวข้อ: วิธีดึง10 กระทู้ล่าสุดมาแสดงที่หน้าแรกของเว็บ  (อ่าน 2479 ครั้ง)

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

ออฟไลน์ smf

  • [color=green][i]"ถ้าคุณไม่สามารถอธิบายอย่างง่ายๆ ให้คนอื่นเข้าใจได้แล้วล่ะก็ แสดงว่าคุณยังเข้าใจมันไม่ดีพอ"[/i][/color]
  • Administrator
  • Hero Member
  • *****
  • กระทู้: 1,368
  • พอยท์: 5
    • ดูรายละเอียด
    • pordoo.com
    • อีเมล์
คือการดึงเอาหัวข้อล่าสุด (Recent topics) ออกมาโชว์ไว้ที่หน้าเว็บอื่นๆของเรา

แบบที่1. ธรรมดาทั่วๆไป ที่ใช้ function จาก ssi_recentTopics


ดูตัวอย่าง : show_ssi_recenttopics1

สร้างไฟล์ Show_ssi_recentTopics1.php :
โค๊ด: [Select]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?php require("webboard/SSI.php"); ?>
<html>
<head>
<meta http-equiv="Content-Language" content="th">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="refresh" content="900" >
<title>วิธีดึง10 กระทู้ล่าสุดแบบ ssi_recentTopics | welovethailand.com</title>
<base target="_blank">
<style type="text/css">

body,td,th {
   font-family: Arial, Helvetica, sans-serif;
   font-size: 12px;
   color: #0066FF;}
a {font-size: 12px;color: #E79A0C;}
a:link { color: navy; text-decoration: none}
a:visited { color: #0000FF; text-decoration: none}
a:active { color: #FF9900; text-decoration: underline}
a:hover { color: Orange; text-decoration: underline}

</style>
</head>

<body >
<!--ดึง recentTopics-->
<?php ssi_recentTopics($num_recent =10 $exclude_boards null$include_boards 1$output_method 'echo'); ?>
<!--หมายเลข 10 คือจำนวนที่จะเเสดง   /   เลข 1 คือ id ของบอร์ดหรือโซนที่จะเเสดง ใส่ null ถ้าต้องการแสดงทุกบอร์ด-->

</body>
</html>
วิธีใช้ : วาง iframe ในตำแหน่งที่เราต้องการให้มันโชว์
โค๊ด: [Select]
<div align="center">
<iframe src="Show_ssi_recentTopics1.php"  frameBorder="0" width="100%" height="225px" scrolling="no"allowtransparency="true"></iframe>
</div>
สิ่งที่ต้องแก้ไข :
1. <?php require("webboard/SSI.php"); ?> วางพาธไฟล์เรียก SSI.php ให้ถูกต้องตามเว็บของท่าน
2. <iframe src="Show_ssi_recentTopics1.php"  วางพาธไฟล์ที่ iframe เรียก Show_ssi_recentTopics1.php ให้ถูกต้องตามเว็บของท่าน
หรือใช้ <?php include("Show_ssi_recentTopics1.php"); ?> ก็ได้ ถ้าไม่ชอบแบบ Iframe เพราะยุ่งยากเรื่องพื้นหลังและความกว้างxยาว



แบบที่2. ssi_recentTopics2 มีตารางกับไม่มีตาราง


ดูตัวอย่าง: show_ssi_recenttopics2

สร้างไฟล์ Show_ssi_recentTopics2.php :
โค๊ด: [Select]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?php require("webboard/SSI.php"); ?>
<html>
<head>
<meta http-equiv="Content-Language" content="th">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="refresh" content="900" >
<title>โชว์กระทู้์ล่าสุด smf2.0.2 | welovethailand.com</title>
<base target="_blank">
<style type="text/css">

body,td,th {
   font-family: Arial, Helvetica, sans-serif;
   font-size: 12px;
   color: #0066FF;}
a {font-size: 12px;color: #E79A0C;}
a:link { color: navy; text-decoration: none}
a:visited { color: #0000FF; text-decoration: none}
a:active { color: #FF9900; text-decoration: underline}
a:hover { color: Orange; text-decoration: underline}
td { height:22px}
</style>
</head>

<body >
<br>
<strong><u>recentTopics แบบ ssi_recentTopics2 แบบไม่ใส่ตาราง</u><br>
</strong><br>
<!--เริ่ม recentTopics แบบ ssi_recentTopics2 แบบไม่ใส่ตาราง-->
<?php
$welovetopic 
ssi_recentTopics('10',array(4,5,6), array(1,2,3),'array'); //10 กระทู้ที่ต้องการให้แสดง, array(4,5,6)บอร์ดที่จะไม่ให้แสดง, array(1,2,3)บอร์ดที่จะให้แสดง ปล่อยว่าง array() มาทุกบอร์ด
foreach ($welovetopic as $post){
echo
'
<a href="'
$post['href'], '">'$post['subject'], ' </a>  '$txt['by'], ' '$post['poster']['link'], ' [อ่าน:'$post['views'],']',' [ตอบ:'$post['replies'],']'' '$post['time'], '<br>
'
;
}
?>

<!--จบ recentTopics แบบ ssi_recentTopics2 แบบไม่ใส่ตาราง-->

<br>
<hr>
<br>
<strong><u>recentTopics แบบ ssi_recentTopics2 แบบใส่ตาราง</u></strong><br>
<br>

<!--เริ่ม recentTopics แบบ ssi_recentTopics2 แบบใส่ตาราง-->
<?php
$welovetopic 
ssi_recentTopics('10',array(4,5,6), array(1,2,3),'array'); //10 กระทู้ที่ต้องการให้แสดง, array(4,5,6)บอร์ดที่จะไม่ให้แสดง, array(1,2,3)บอร์ดที่จะให้แสดง ปล่อยว่าง array() มาทุกบอร์ด (ให้ใส่เพียงอันใดอันหนึ่งแล้วเว้นว่างอีกอันหนึ่งไว้)
echo'
<table width="640" border="1" cellpadding="0" cellspacing="0" bordercolor="#E8E8E8">
  <tr>
    <td width="380" bgcolor="#F4F4F4"><div align="center"><strong>หัวข้อ</strong></div></td>
    <td width="40" bgcolor="#F4F4F4"><div align="center"><strong>อ่าน</strong></div></td>
    <td width="40" bgcolor="#F4F4F4"><div align="center"><strong>ตอบ</strong></div></td>
    <td width="180" bgcolor="#F4F4F4"><div align="center"><strong>วัน/เวลา</strong></div></td>
  </tr>'
;
  
  foreach (
$welovetopic as $post)
  {
  echo
'
  <tr>
    <td><a href="'
$post['href'], '">'$post['subject'], ' </a>'$txt['by'], ' '$post['poster']['link'], '</td>
    <td bgcolor="#F4F4F4"><div align="center">'
$post['views'],'</div></td>
    <td bgcolor="#F4F4F4"><div align="center">'
,$post['replies'],'</div></td>
    <td bgcolor="#F4F4F4"><div align="center">'
$post['time'],'</div></td>
  </tr>'
;
  }
  echo
'
    <tr>
    <td bgcolor="#F4F4F4">&nbsp;</td>
    <td bgcolor="#F4F4F4">&nbsp;</td>
    <td bgcolor="#F4F4F4">&nbsp;</td>
    <td bgcolor="#F4F4F4">&nbsp;</td>
  </tr>
</table>
'
;
?>

<!--จบ recentTopics แบบ ssi_recentTopics2 แบบใส่ตาราง-->
</body>
</html>
วิธีใช้ : วาง iframe ในตำแหน่งที่เราต้องการให้มันโชว์
   
โค๊ด: [Select]
<div align="center">
    <iframe src="Show_ssi_recentTopics2.php" frameBorder="0" width="100%" height="600px" scrolling="no"allowtransparency="true"></iframe>
    </div>
สิ่งที่ต้องแก้ไข :
1. <?php require("webboard/SSI.php"); ?> วางพาธไฟล์เรียก SSI.php ให้ถูกต้องตามเว็บของท่าน
2. <iframe src="Show_ssi_recentTopics2.php"  วางพาธไฟล์ที่ iframe เรียก Show_ssi_recentTopics2.php ให้ถูกต้องตามเว็บของท่าน
หรือใช้ <?php include("Show_ssi_recentTopics2.php"); ?> ก็ได้ ถ้าไม่ชอบแบบ Iframe เพราะยุ่งยากเรื่องพื้นหลังและความกว้างxยาว
3. เปลี่ยนบอร์ดที่ต้องการให้แสดงหรือไม่แสดงได้ตรงที่ array(4,5,6), array(1,2,3) ปล่อยว่าง array() มาทุกบอร์ด ผมทำตัวอย่างไว้2แบบ ให้เลือกใช้แบบใดแบบหนึ่ง  ตัวอย่างเช่น ssi_recentTopics('10',array(4,5,6), array(),'array');  //4,5,6 คือกั้นบอร์ดที่ไม่ต้องการให้แสดง ที่เหลือปล่อยไว้เป็นต้น

หมายเหตุ
       เมื่อใส่ บอร์ดที่ไม่ให้แสดง array(4,5,6) นานๆไป Recent Topics มักจะลดจำนวนเหลือน้อยลงจนหายเกลี้ยง  อธิบายดังนี้ Recent Topics เป็นการนำบทความล่าสุดมาแสดงตามจำนวน เช่น จำนวนกระทู้ที่ต้องการให้แสดง 20 ถ้าสั่งให้แสดงทุกๆบอร์ด แม้ไม่มีกระทู้เข้ามาใหม่ บทความเก่าล่าสุดก็ยังแสดงอยู่ แต่ถ้าเมื่อไหร่มีคำสั่งให้ ไม่แสดงบอร์ดใดๆร่วมด้วย และบอร์ดที่ไม่ให้แสดงมีจำนวนกระทู้ใหม่มากกว่า บอร์ดที่แสดงในหน้ารวมกระทู้จนมากขึ้นไปเรื่อยๆ จึงทำให้หน้ารวมกระทู้ Recent Topics ถูกลดจำนวนลงไปจนหายเกลี้ยง เพราะกระทู้ที่แสดงถูกแทนที่ด้วย20บทความใหม่ ที่ถูกไม่ให้แสดง หน้าจึงว่างเปล่า
ยกตัวอย่าง array(4,5,6)บอร์ดที่จะไม่ให้แสดง สมุติว่าบอร์ดที่ 4,5,6 คือบอร์ดเกี่ยวกับให้ลงประกาศโฆษณาฟรี เราไม่ต้องการให้แสดงในหน้ารวมกระทู้ Recent Topics เราให้ array(1,2,3)บอร์ดที่จะให้แสดง เป็นบอร์ดหลักที่ต้องการให้แสดงผลที่หน้ารวมกระทู้เท่านั้น แต่บังเอิญ บอร์ดหลักของเว็บเราดันมีบทความอัพเดทน้อยกว่าบอร์ดที่ให้ลงประกาศโฆษณา ฟรี จึงทำให้ บทความที่ลงประกาศโฆษณาฟรี มีจำนวนเพิ่มขึ้นเรื่อยๆจนเกินจำนวน 20 กระทู้ทีเราตั้งโชว์ไว้ ในเมื่อ Recent Topics ถูกให้โชว์กระทู้ล่าสุดที่ 20 กระทู้ แต่แล้ว บอร์ดที่ 4,5,6 คือบอร์ดเกี่ยวกับให้ลงประกาศโฆษณาฟรี กลับถูกงดให้แสดง ดังนั้นในหน้ารวมกระทู้ Recent Topics จึงไม่มีอะไรเหลือให้แสดงอีกจนกว่าเราจะไปโพสท์บทความใหม่ๆ ของบอร์ดหลัก (1,2,3)บอร์ดที่จะให้แสดง เพิ่มกระทู้ใหม่ขึ้นมาจนมากกว่าบอร์ด ลงประกาศโฆษณาฟรี (บอร์ดที่จะไม่ให้แสดง) เมื่อนั้นจึงมีบทความใหม่ๆแสดงให้เห็น นี่คือหลักของ Recent Post - Topics ถ้าต้องการแสดงแยกเดีี่ยวๆ แนะนำไม่ให้ใช้ Function Recent หรือถ้าจะใช้ต้องสั่งแสดงทุกบอร์ดหรือไม่บอร์ดหลักของเราต้องมีกระทู้โพสท์ใหม่ๆ มากกว่าบอร์ดที่ไม่ต้องการให้แสดง



แบบที่3. ssi_recentTopics3 (แบบ Hot)

ดูตัวอย่าง: show_ssi_recenttopics3 (Hot)
โค๊ด: [Select]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?php require("webboard/SSI.php"); ?>
<html>
<head>
<meta http-equiv="Content-Language" content="th">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="refresh" content="900" >
<title>โชว์กระทู้์ล่าสุด smf2.0.2 | welovethailand.com</title>
<base target="_blank">
<style type="text/css">

body,td,th {
   font-family: Arial, Helvetica, sans-serif;
   font-size: 12px;
   color: #464646;}
a {font-size: 12px;color: #263875;}
a:link { color: #263875; text-decoration: none}
a:visited { color: #263875; text-decoration: none}
a:active { color: #FF9900; text-decoration: underline}
a:hover { color: #48A4FF; text-decoration: underline}
//td { height:15px}
.virep {color: #666666}
</style>
</head>

<body >
<!--เริ่ม recentTopics แบบ ssi_recentTopics3 -->
<?php
$welovetopic 
ssi_recentTopics('20',array(), array(),'array'); 
//20 จำนวนกระทู้ที่ต้องการให้แสดง , array(4,5,6)บอร์ดที่จะไม่ให้แสดง,  array(1,2,3)บอร์ดที่จะให้แสดง และปล่อยว่าง array() แสดงทุกบอร์ด
foreach ($welovetopic as $post)
{
echo 
'
      <table border="0" width="100%">'
;
echo 
'
         <tr>

            <td>
               <b><a href="'
$post['href'], '">'$post['subject'], '</a></b>
               '
$txt['by'], ' '$post['poster']['link'], ' <span class="virep">['$txt['views'], ' '$post['views'],'] ['$txt['replies'], ' ',$post['replies'],']</span>
               '
, !$post['is_new'] ? '' '<a href="' $scripturl '?topic=' $post['topic'] . '.msg' $post['new_from'] . ';topicseen#new" rel="nofollow"><img src="' $settings['lang_images_url'] . '/new.gif" alt="' $txt['new'] . '" /></a>''
            </td>
            
               <td align="right">['
$post['board']['link'], '] '$post['time'], '</td>
            
         </tr>'
;
echo 
'
      </table>'
;
}
?>

<!--จบ recentTopics แบบ ssi_recentTopics3 -->

</body>
</html>
การแก้ไขและการใช้งานก็แบบเดียวกันกับด้านบน สามารถเอาไปประยุคใช้แทน กระทู้เมื่อเร็วๆนี้ที่หน้าบอร์ดได้ แบบไม่มี Re:



แบบที่4. ssi_recentTopics4  Full Table


ดูตัวอย่าง: show_ssi_recenttopics4 (Hot)

โค๊ด: [Select]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?php require("webboard/SSI.php"); ?>
<html>
<head>
<meta http-equiv="Content-Language" content="th">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="refresh" content="900" >
<title>โชว์กระทู้์ล่าสุด smf2.0.2 | welovethailand.com</title>
<base target="_blank">
<style type="text/css">

body,td,th {
   font-family: Arial, Helvetica, sans-serif;
   font-size: 12px;
   color: #464646;}
a {font-size: 12px;color: #263875;}
a:link { color: #263875; text-decoration: none}
a:visited { color: #263875; text-decoration: none}
a:active { color: #FF9900; text-decoration: underline}
a:hover { color: #48A4FF; text-decoration: underline}
//td { height:22px}
.virep {color: #666666}
</style>
</head>

<body >
<!--เริ่ม recentTopics แบบ ssi_recentTopics4 full table -->
<?php
$welovetopic 
ssi_recentTopics('20',array(), array(),'array'); 
//20 จำนวนกระทู้ที่ต้องการให้แสดง , array(4,5,6)บอร์ดที่จะไม่ให้แสดง,  array(1,2,3)บอร์ดที่จะให้แสดง และปล่อยว่าง array() แสดงทุกบอร์ด
foreach ($welovetopic as $post)
{
echo 
'
      <table border="0" width="1024">'
;
echo 
'
      <tr>
      <td width="540">
      <b><a href="'
$post['href'], '">'$post['subject'], '</a></b>
               '
$txt['by'], ' '$post['poster']['link'], 
      '
, !$post['is_new'] ? '' '<a href="' $scripturl '?topic=' $post['topic'] . '.msg' $post['new_from'] . ';topicseen#new" rel="nofollow"><img src="' $settings['lang_images_url'] . '/new.gif" alt="' $txt['new'] . '" /></a>''
      </td>
      <td width="124"align="right"><span class="virep">['
$txt['views'], ' '$post['views'],'] ['$txt['replies'], ' ',$post['replies'],']</span></td>
            
      <td width="180"align="right">['
$post['board']['link'], ']</td> 
      <td width="180"align="right">'
$post['time'], '</td>
            
      </tr>'
;
echo 
'
      </table>'
;
}
?>

<!--จบ recentTopics แบบ ssi_recentTopics4 full table-->

</body>
</html>

การแก้ไขการใช้งานก็แบบเดียวกันกับด้านบน สามารถเอาไปประยุคใช้แทน กระทู้เมื่อเร็วๆนี้ที่หน้าบอร์ดได้ แบบไม่มี Re:
***อธิบายเพิ่มเติม การปรับแต่ง***
ตาราง <table border="0" width="1024">';
ssi_recentTopics4 full table เป็นแบบตาราง 4 คอลัมน์ แต่ซ่อนไว้ด้วยการใส่ 0 ที่ border ถ้าต้องการให้แสดงตารางใส่ 1
ส่วนความกว้าง แต่ละบอร์ดไม่เหมือนกันให้เปลี่ยนที่ width="1024" ถ้าบอร์ดใดใช้เป็นแบบ เปอร์เซ็นต์ 100% ก็เปลี่ยนตามนั้น

คอลัมน์ <td width="540">
แต่ละคอลัมน์ ต้องเปลี่ยนให้สมพันธ์กันด้วย

การนำไปประยุคใช้งาน เนื่องจากผมใส่ตัวแปร $post ต่างๆไว้ครบชัดเจนหมดแล้ว
จึงสามารถเคลื่อนย้ายและตัดทิ้งตัวแปร $post ต่างๆได้ตามชอบใจดังนี้

หัวข้อ =
', $post['href'], '">', $post['subject'], '
โดย = ', $txt['by'], ' ', $post['poster']['link'], '

Icon New = ', !$post['is_new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" /></a>', '
[อ่าน ] [ตอบ ] = [', $txt['views'], ' ', $post['views'],'] [', $txt['replies'], ' ',$post['replies'],']
ชื่อบอร์ด = [', $post['board']['link'], ']
วันเวลา = ', $post['time'], '

วิธีตัดคำให้สั้นลง
เปลี่ยนจาก ', $post['subject'],'
เป็น  ',mb_substr($post['subject'],0,30,'UTF-8'),'....
30 คือ จำนวนตัวอักษรที่ต้องการตัดคำให้แสดงเพียงเท่านั้น...

เพิ่มเติม การเพิ่ม icon ก่อนกระทู้  ให้แทรกคอลัมน์ <td width="15"> หลัง <tr>

นำโค้ดนี้ไปใส่
   <td width="15">
   <img src="' . $settings['images_url'] . '/icons/bb_icon.png" alt="' . $txt['new'] . '" /></a>
   </td>

แล้วอัพโหลดรูป icon bb_icon.png ไปไว้ที่ Themes/ธีมปัจจุบันที่ใช้/images/icons/icon bb_icon.png

หรือเติม icon ของบอร์ดโดยอัตโนมัติ
', $post['icon'], '

เพิ่มเติม
$post['preview']  แสดงรายละเอียด แสดงรายละเอียดได้สูงสุดที่ 128 ตัวเท่านั้น
$post['short_subject'] แสดงหัวข้อสั้นๆ แสดงหัวข้อสั้นๆสูงสุดที่  25 ตัวเท่านั้น

*หมายเหตุ สร้างขอบตรางสีฟ้าบน-ล่างแบบในตัวอย่าง*
สร้าง Show_iframe_ssi_recentTopics4.php ให้เป็นเสมือนหน้าเพจหลัก (home) ก่อนแล้วดึง iframe หรือ include โชว์ 10 กระทู้มาแสดงในหน้าเพจหลักอีกทีหนึ่ง
โค้ดดังนี้  Show_iframe_ssi_recentTopics4.php
โค๊ด: [Select]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>โชว์กระทู้์ล่าสุด smf2.0.2 | welovethailand.com</title>
<base target="_blank">
<style type="text/css">

.style1 {
   font-family: Tahoma,Arial, Helvetica, sans-serif;
   font-size: 14px;
   color: #FFFFFF;
}
.style2 {
   font-family: Tahoma,Arial, Helvetica, sans-serif;   
   margin-right: 10px;
   text-align:right;
   color: #FFFFFF;
}

</style>
</head>

<body>
<table width="1024" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
  <tr>
    <td height="30" bgcolor="#62A0FF"><div align="center" class="style1">โชว์กระทู้์ล่าสุด smf2.0.2 แบบ ssi_recentTopics 4 Full Table</div></td>
  </tr>
  <tr>
    <td>
    <div align="center">
        <?php include("Show_ssi_recentTopics4.php"); ?>
   <!-- <iframe src="Show_ssi_recentTopics4.php" frameBorder="0" width="100%" height="480px" scrolling="no"allowtransparency="true"></iframe>-->
    </div>
    </td>
  </tr>
  <tr>
    <td height="30" bgcolor="#62A0FF" ><div class="style1 style2">welovethailand.com</div></td>
  </tr>
</table>
</body>
</html>
สรุปแบบในตัวอย่างคือการสร้าง 2 เพจ  Show_iframe_ssi_recentTopics4.php คือหน้าหลักมีขอบตารางสีฟ้าบน-ล่างหน้านี้อาจเป็นหน้า homepage มีเมนู login-out ป้ายแบนเนอร์ต่างๆร่วมด้วยก็ได้นะครับ กับ Show_ssi_recentTopics4.php ดึงกระทู้ล่าสุดมาโชว์ร่วม

credit: http://www.welovethailand.com/webboard/index.php?topic=173.0
« แก้ไขครั้งสุดท้าย: 31 มกราคม 2016, 02:38:32 โดย smf »

ออฟไลน์ smf

  • [color=green][i]"ถ้าคุณไม่สามารถอธิบายอย่างง่ายๆ ให้คนอื่นเข้าใจได้แล้วล่ะก็ แสดงว่าคุณยังเข้าใจมันไม่ดีพอ"[/i][/color]
  • Administrator
  • Hero Member
  • *****
  • กระทู้: 1,368
  • พอยท์: 5
    • ดูรายละเอียด
    • pordoo.com
    • อีเมล์
หัวข้อล่าสุด แบบการเขียนเรียกไฟล์ดึงออกมาเองจากฐานข้อมูลโดยตรง เพื่อใส่ลูกเล่นต่างๆ เช่นจัดตารางได้ตามใจชอบฯลฯ เลือกบอร์ดได้ กำหนดจำนวนกระทู้ได้ มีหลายรูปแบบ พร้อมไฟล์ตกแต่ง CSS ดังนี้

แบบ List ทั่วๆไป


แบบ List และ Icon Image


แบบตาราง 3 คอลัมน์


แบบตาราง 5 คอลัมน์


แบบตารางสีฟ้า 5 คอลัมน์
credit: http://www.welovethailand.com/webboard/index.php?topic=173.0
« แก้ไขครั้งสุดท้าย: 31 มกราคม 2016, 02:28:02 โดย smf »

ออฟไลน์ smf

  • [color=green][i]"ถ้าคุณไม่สามารถอธิบายอย่างง่ายๆ ให้คนอื่นเข้าใจได้แล้วล่ะก็ แสดงว่าคุณยังเข้าใจมันไม่ดีพอ"[/i][/color]
  • Administrator
  • Hero Member
  • *****
  • กระทู้: 1,368
  • พอยท์: 5
    • ดูรายละเอียด
    • pordoo.com
    • อีเมล์
การดึง10 กระทู้ล่าสุดของแต่ละหัวข้อมาทำ content ในหน้าแรกที่สร้างใหม่
โค๊ด: [Select]
<?php 

$list 
"20"// ต้องการให้โชว์กี่กระทู้ล่ะ ใส่เข้าไปได้เลย

$sboard "0"// ใส่ 0 ถ้าต้องการกระทู้จากบอร์ดทุกบอร์ด  และใส่ 1 ถ้าต้องการเจาะจงบอร์ด

// ถ้าใส่ 1 อย่าลืมระบุ id ของบอร์ดด้วยเช่น 
// http://www.xxx.com/forum/lasttopic.php?board= อย่างงี้อ่ะ เช่น http://www.xxx.com/forum/lasttopic.php?board=3.0

// ถ้าไม่ได้ใส่ ?board=.. ก็ให้มันแสดงตาม id ของบอร์ด ตามข้างล่าง
/*
if (empty($board)) { 
$board = "2"; // เปลี่ยนตรงนี้ถ้าอยากให้บอร์ดไหนเป็นค่า default 

*/

?>


<html>

<head>

<meta http-equiv="Content-Language" content="th">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="page_style.css">

<title>:: <?=$list ?> กระทู้ล่าสุดจากบอร์ด DexMore.Com</title>
<base target="_blank">

<style type="text/css">
<!--
.style1 {font-size: 13px}
-->
</style>

</head>

<body bgcolor=#E5E5FF>
<span class="style1">

<?
include("Settings.php");

$host = $db_server;
$user = $db_user;
$pass = $db_passwd;
$database = $db_name;
$prefix = $db_prefix."topics";
$prefix2 = $db_prefix."messages";

@mysql_connect($host,$user,$pass) or die("ขออภัยค่ะ ขณะนี้ไม่สามารถติดต่อฐานข้อมูลได้ กรุณาเข้าชมใหม่ภายหลัง");
if ($sboard=="0") {
$Sql = "SELECT * FROM $prefix order by ID_TOPIC DESC limit 0,$list ";
} elseif ($sboard=="1") {
$Sql = "SELECT * FROM $prefix where ID_BOARD='$board' order by ID_TOPIC DESC limit 0,$list ";
}
$result = mysql_db_query($database,$Sql);
$nrow = mysql_num_rows($result);
while ($num = mysql_fetch_array($result)) {

$tid = $num["ID_TOPIC"];
$bid = $num["ID_BOARD"];
$fid = $num["ID_FIRST_MSG"];
$view = $num["numViews"];
$reply = $num["numReplies"];

$msql = "select * from $prefix2 where ID_MSG='$fid'";
$mresult = mysql_db_query($database,$msql);
$marr = mysql_fetch_array($mresult);
$title = $marr["subject"];
$poster = $marr["posterName"];
$today = date("d M Y");
$time = date("d M Y", $marr["posterTime"]);
if ($today==$time) {
$time = date("<font color='#FF0000'><b>วันนี้ .</font></b>", $marr["posterTime"]);
} else {
$time = date("<b>เมื่อวานนี้ .</b>", $marr["posterTime"]);
}

echo "<span class='font'>\n";
echo "<img src=http://www.freepgs.com/xtech/forums/Themes/default/images/forum.gif width=12 height=8 border=0 alt='Topic $tid'>&nbsp;\n";
echo "<a href='index.php?board=$bid;action=display;threadid=$tid' target='_blank'><b>$title</b></a> โดย $poster <font color=#0000ff><b>:</b> $time</font> (อ่าน view/ตอบ reply) </span><br>\n";
}

?>

</span>
</body>

</html>
ขอบคุณ:DexMore.Com