วิธีดึงกระทู้ล่าสุดจากบอร์ดแต่ละบอร์ด(SMF)

วิธีดึงกระทู้ล่าสุดจากบอร์ดแต่ละบอร์ด(SMF)

วิธีดึงกระทู้ล่าสุดจากบอร์ดแต่ละบอร์ด(SMF)
<?php
include 'SSI.php';

ssi_recentPosts(10, array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30));
?>


// Recent post list:   Subject by Poster   Date
function ssi_recentPosts($num_recent = 8, $exclude_boards = null, $output_method = 'echo')

พารามิเตอร์ ตัวแรกคือจำนวนโพส
ตัวถัดมาก็คือ exclude boards แปลว่า id board ที่ไม่เอาครับ เก็บเป็นอาเรย์ ในตัวอย่างผมไม่เอาตั้งแต่ 1-30 ก็เลยเหลือบอร์ดเดียว (สำหรับเว็บผม)
พารามิเตอร์ตัวสุดท้าย คือบีบให้เอ้้าพุตเป็น html เราต้อง echo อันนี้ไม่ต้องสนใจ

ถ้าเกิดอันนี้ใช่ที่ต้องการ เราสามารถไปแก้ลักษณะข้อความได้ข้างล่างฟังชันท์
แถวๆ
if(!$post<'topic'><'allowed'>) {

มันก็เกือบใช่ครับแต่ว่าอยากได้รูปแบบ

มี 1. ตาม ด้วย ชื่อ กระทู้  ตาม ด้วย โพสโดย

แบบนี้อะครับได้ไหม

ฟอร์แมทที่คุณต้องการ แก้ได้ที่ฟังชันท์ ssi_recentPost ในไฟล์ SSI.php

เปิดเข้าไปในฟังชันท์ แล้วหาส่วนที่เขียนว่า echo
มันจะเป็นส่วนแสดงผล ใช้เซ็นส์ และความพยายามในการสร้าง HTML ในแบบที่คุณต้องการ

<?php ssi_recentTopics($num_recent = 15, $exclude_boards = null, $include_boards = 1, $output_method = 'echo'); ?>
15 คือ จำนวนหัวข้อ
1 คือ หมวดของบอร์ด
นำไปวางในจุดที่คุณต้องการแสดง
อย่าลืม include

ssi.php

เขียนสคริป ดึงข้อมูลมาจาก mysql
<?
################
//   แสดง 10 หัวข้อสุดท้ายใน YaBB   //
#แก้ไข config
################
$username = "username"; //ชื่อเข้า DB
$password = "password"; //รหัสเข้า DB
$host = "localhost";
$dbname = "DB_name"; //ชื่อ DB ของเรา
################
$db = mysql_connect($host,$username,$password) or die ("ไม่สามารถติดต่อกับฐานข้อมูลได้ในขณะนี้");
#เรียกข้อมูลจาก Forum
// บรรทัดด้านล่าง ตรง smf_topic ด้านหน้าถ้าไม่ได้ใช้ default ก็ให้แก้ไขตามจริง , limit คือจำนวนกระทู้ที่ต้องการให้แสดง , Board คือ Board ID ที่ต้องการ
$SelectForum = "select * from smf_topics where ID_BOARD='1' order by ID_TOPIC DESC Limit 10";
$SelectForumRe = mysql_db_query($dbname,$SelectForum) or die ("ติดต่อไม่ได้ในขณะนี้ 1");
while($FetchForumG = mysql_fetch_row($SelectForumRe)){
$sqltopic = "select * from smf_messages where ID_TOPIC ='$FetchForumG<0>' AND ID_MSG ='$FetchForumG<4>' order by poster_time DESC ";

$retopic = mysql_db_query($dbname,$sqltopic) or die ("ติดต่อไม่ได้ในขณะนี้ 2");
$fetchtopic = mysql_fetch_row( $retopic );
#ถ้า description ยาวเกินให้ตัดออก
$CuteDescription = strlen($fetchtopic<6>);
if ( $CuteDescription > $NumTopicDesc )
{
$CuteDescription = substr($fetchtopic<6>,0,$NumTopicDesc) . "...";
} else {
$CuteDescription = $fetchtopic<6>;
};
               // บรรทัดด้านล่าง ใส่ URL ของเว็บคุณ
echo "<img src=\"images/bullet.jpg\" width=\"13\" height=\"8\"> <a href=\"http://www.domain.com/index.php?board=$FetchForumG<1>;action=display;threadid=$FetchForumG<0>\" target=\"_blank\"><strong><font color=\"#FFFFFF\">$CuteDescription</font></strong> <font color=\"#FF0000\">โดย $fetchtopic<7></font></a><br>";
};
?>


หรือ
<?php require("SSI.php"); ?>
<?php ssi_topTopicsViews(); ?>


ID=1488,MSG=1658
Re: วิธีดึงกระทู้ล่าสุดจากบอร์ดแต่ละบอร์ด(SMF)

Re: วิธีดึงกระทู้ล่าสุดจากบอร์ดแต่ละบอร์ด(SMF)

หลังจากอัพเกรด SMF รุ่นหลังๆ จะต้องไปตั้งค่าให้อนุญาติดึงโดยเว็บอื่นได้ เว็บอื่นจึงจะสามารถดึงไปใช้ได้

ตัวอย่างแบบอื่นๆ

<?php

require("/home/พาร์ไดเรคทอรี่เว็บ.คอม/public_html/webboard/SSI.php"); // --- โค้ดตรงนี้ของแต่ละเว็บจะไม่เหมือนกันนะ  ให้ดูที่หน้า ssi_examples.php ในเว็บคุณ

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

$sboard = "1"; // ใส่ 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=windows-874">
<link rel="stylesheet" type="text/css" href="page_style.css">

<title>:: <?=$list ?> กระทู้ล่าสุดข่าวกัลโช่ ::</title>
<base target="_blank">

<style type="text/css">
<!--
.style1 {font-size: 13px}
body,td,th {
font-size: 12px;
color: #00CC00;
}
a:link {
text-decoration: none;
color: #00CC00;
}
a:visited {
text-decoration: none;
color: #00CC00;
}
a:hover {
text-decoration: none;
color: #FFFFFF;
}
a:active {
text-decoration: none;
color: #00CC00;
}
a {
font-size: 12px;
color: #E79A0C;
}
body {
background-color: #000000;
}
-->
</style>

</head>

<body>
<p 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">;

$msql = "select * from $prefix2 where ID_MSG='$fid'";
$mresult = mysql_db_query($database,$msql);
$marr = mysql_fetch_array($mresult);
$title = $marr<"subject">;

echo "<span class='font'>\n";
echo "<img src=http://www.romathai.com/icon/Calcio-16x16.gif width=16 height=16 border=0>&nbsp;\n"; 
echo "<a href='index.php?board=$bid;action=display;threadid=$tid' target='_blank'>$title</a><br>\n";
}

?>
</p>
<p class="style1"><br>
&nbsp;<a href="http://www.romathai.com/forum/index.php?board=4.20" target="_blank">&nbsp;&nbsp;&nbsp;&nbsp; อ่านข่าวย้อนหลัง...</a></p>
</body>

</html>


ID=1488,MSG=3081
Re: วิธีดึงกระทู้ล่าสุดจากบอร์ดแต่ละบอร์ด(SMF)

Re: วิธีดึงกระทู้ล่าสุดจากบอร์ดแต่ละบอร์ด(SMF)

<!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>


ID=1488,MSG=3082
Re: วิธีดึงกระทู้ล่าสุดจากบอร์ดแต่ละบอร์ด(SMF)

Re: วิธีดึงกระทู้ล่าสุดจากบอร์ดแต่ละบอร์ด(SMF)

อ้างอิง http://www.welovethailand.com/webboard/index.php?topic=173.0

อื่นๆ
http://www.welovethailand.com/webboard/index.php/topic,4435.0.html


ID=1488,MSG=3083
Re: วิธีดึงกระทู้ล่าสุดจากบอร์ดแต่ละบอร์ด(SMF)

Re: วิธีดึงกระทู้ล่าสุดจากบอร์ดแต่ละบอร์ด(SMF)

แบบนี้โอเค


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?php require("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</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 = 7, $output_method = 'echo'); ?>
<!--หมายเลข 10 คือจำนวนที่จะเเสดง  /  เลข 1 คือ id ของบอร์ดหรือโซนที่จะเเสดง ใส่ null ถ้าต้องการแสดงทุกบอร์ด-->

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



เวลาใช้ ให้สร้างไฟล์นี้ขึ้นมาแล้ว include หรือ iframe
หรือ ใส่โค๊ดนี้ในหน้าเว็บนั้นๆเลยก็ได้


ID=1488,MSG=3084


⭐️ เราให้คำแนะนำปรึกษา รักษาผลประโยชน์ให้ลูกค้า ของเรา
⭐️ เราอยู่เคียงข้างลูกค้าของเรา ช่วยเหลือ ดูแลบริการ
⭐️ เรารองรับช่องทางติดต่อมากมาย สะดวก เข้าถึงง่าย
⭐️ เราดำเนินธุรกิจยาวนานกว่า20 ปี คุณจึงมั่นใจได้
⭐️ คุณมีสามารถรับบริการทั้งจากบริษัทประกันเจ้าของสินค้า และ เรา (ตัวกลาง)

ไทย มีราว 80 บริษัทประกันภัย สินค้าที่แตกต่าง ทั้ง เงื่อนไข ราคา เคลม ความมั่นคง นโยบาย ฯลฯ
ขายผ่านตัวกลาง กว่า 500,000 ราย : ตัวแทน นายหน้า ธนาคาร บิ๊กซี โลตัส ค่ายรถยนต์ เฮ้าส์แบรนด์ ของประกันภัย หรือ ซื้อตรงกับบริษัทเจ้าของสินค้า
⭐️ ตัวอย่าง การบริการ กดดูที่ลิงค์นี้

"สิ่งที่ต้องคำนึงอันดับแรกในการซื้อประกัน คือ ตัวกลางประกันภัย ซึ่งจะเป็นที่ปรึกษา ช่วยเหลือ ดูแลเรา ตลอดอายุกรมธรรม์"

โปรดรอ

display:inline-block; position:relative;
โทร.(จ-ศ : 9-16) เว้นวันหยุดฯ , ลูกค้าเรา บริการ 24/7/365 , Friday เวลา 12:52:58pm เที่ยง ปิดทำการ
Copyright © 2018 Cymiz.com., All rights reserved.นโยบาย,ข้อตกลงcymiz.com