smf ดึงรูปและหัวข้อมาแสดงหน้าแรกอย่างไง

เริ่มโดย koclup1580, 18 กรกฎาคม 2012, 10:11:38

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

koclup1580

พอดีหาในgoogleแล้วทำตามแล้วไม่ได้เลยครับใครมีโค๊ตที่ดึงได้บ้างครับช่วยหน่อย :wanwan017:

ken2

ช่วงนี้ไม่ค่อยว่าง
[direct=http://ubncenter.com]ลงประกาศฟรี[/direct] [direct=http://triptourthailand.net]ท่องเที่ยวไทย[/direct] [direct=http://isanbanhao.com/index.php?board=1.0]อาหารอีสาน[/direct]

koclup1580

อ้างถึงจาก: ken2 ใน 18 กรกฎาคม 2012, 10:25:21
ลองดูกระทู้นี้ครับ

http://www.thaiseoboard.com/index.php/topic,186333.0.html

ทำตามอันนี้แล้วแต่มันไม่ได้ ใครมีโค๊ตที่แก้แล้วของ SSI.php บ้างขอหน่อย หรือมีวิธีอื่นไหม ตอบทีครับ :wanwan017:

koclup1580

#3
มันต้องรวมในSSIเป็นแบบนี้ใช่ไหม
function findIMG($text){
preg_match_all('/\[img\].*?\[\/img\]/i',$text,$page);
foreach($page as $value)
$src = substr($value[0],5);
$src = substr($src,0,-6);
return($src);
}
function ssi_pic($num_top = 12,$order,$board)
{
global $context, $settings, $db_prefix, $txt, $scripturl, $ID_MEMBER, $user_info, $modSettings;
// Find boards with lots of posts.
$request = db_query("
SELECT t.ID_TOPIC,m.body,m.subject
FROM ({$db_prefix}topics as t , {$db_prefix}messages as m)
WHERE t.ID_FIRST_MSG=m.ID_MSG AND t.ID_BOARD=$board
ORDER BY t.".$order." DESC
LIMIT $num_top", __FILE__, __LINE__);
$topics = array();
while ($row = mysql_fetch_assoc($request))
{
$topics[] = array(
'id' => $row['ID_TOPIC'],
'body' => $row['body'],
'subject' => $row['subject']
);
}
mysql_free_result($request);
foreach ($topics as $data){
$topic = "forum/?topic=".$data['id'];
$srcPic = findIMG($data['body']);
$subject = $data['subject'];
echo '<div class="boxpGal">
<div class="picpGal"><a href="'.$srcPic.'" title="คริกเพื่อดูภาพเต็ม."><img src="'.$srcPic.'" width="150" alt="" /></a></div><center>'.mb_substr($subject,0,25,'UTF-8').'</center>
<div class="viewAllpic"><a href="'.$topic.'" target="_blank">More info</a></div>   
</div>';
}
}


ken2


ผมเอาวางไว้ไฟล์ SSI.php ด้านล่างเลยครับ ได้ประมาณนี้

อ้างถึง
   // If $id is null, this was most likely called from a query string and should do nothing.
   if ($id === null)
      return;

   $request = db_query("
      SELECT passwd, memberName, is_activated
      FROM {$db_prefix}members
      WHERE " . ($is_username ? 'memberName' : 'ID_MEMBER') . " = '$id'
      LIMIT 1", __FILE__, __LINE__);
   list ($pass, $user, $active) = mysql_fetch_row($request);
   mysql_free_result($request);

   return sha1(strtolower($user) . $password) == $pass && $active == 1;
}

// โค้ดโชว์รูปหน้าแรก

function findIMG($text){
   preg_match_all('/\[img\].*?\[\/img\]/i',$text,$page);
   foreach($page as $value)
      $src = substr($value[0],5);
   $src = substr($src,0,-6);
   return($src);
}

function ssi_pic($num_top = 12,$order,$board)
{
   global $context, $settings, $db_prefix, $txt, $scripturl, $ID_MEMBER, $user_info, $modSettings;
   // Find boards with lots of posts.
   $request = db_query("
      SELECT t.ID_TOPIC,m.body,m.subject
      FROM ({$db_prefix}topics as t , {$db_prefix}messages as m)
      WHERE t.ID_FIRST_MSG=m.ID_MSG AND t.ID_BOARD=$board
      ORDER BY t.".$order." DESC
      LIMIT $num_top", __FILE__, __LINE__);
   $topics = array();
   while ($row = mysql_fetch_assoc($request))
   {
      $topics[] = array(
         'id' => $row['ID_TOPIC'],
         'body' => $row['body'],
         'subject' => $row['subject']
      );
   }
   mysql_free_result($request);
   foreach ($topics as $data){
      $topic = "forum/?topic=".$data['id'];
      $srcPic = findIMG($data['body']);
      $subject = $data['subject'];
      echo '<div class="boxpGal">
         <div class="picpGal"><a href="'.$srcPic.'" title="คริกเพื่อดูภาพเต็ม."><img src="'.$srcPic.'" width="150" alt="" /></a></div><center>'.mb_substr($subject,0,25,'UTF-8').'</center>
         <div class="viewAllpic"><a href="'.$topic.'" target="_blank">More info</a></div>   
      </div>';
   }
}

?>

แล้วก็เอาโค้ดนี้ไปใส่ในไฟล์ BoardIndex.template.php ตรงที่ต้องการให้แสดง

อ้างถึงssi_pic(10,'ID_TOPIC',1);

ช่วงนี้ไม่ค่อยว่าง
[direct=http://ubncenter.com]ลงประกาศฟรี[/direct] [direct=http://triptourthailand.net]ท่องเที่ยวไทย[/direct] [direct=http://isanbanhao.com/index.php?board=1.0]อาหารอีสาน[/direct]

koclup1580

อ้างถึงจาก: ken2 ใน 18 กรกฎาคม 2012, 11:36:39

ผมเอาวางไว้ไฟล์ SSI.php ด้านล่างเลยครับ ได้ประมาณนี้

อ้างถึง
   // If $id is null, this was most likely called from a query string and should do nothing.
   if ($id === null)
      return;

   $request = db_query("
      SELECT passwd, memberName, is_activated
      FROM {$db_prefix}members
      WHERE " . ($is_username ? 'memberName' : 'ID_MEMBER') . " = '$id'
      LIMIT 1", __FILE__, __LINE__);
   list ($pass, $user, $active) = mysql_fetch_row($request);
   mysql_free_result($request);

   return sha1(strtolower($user) . $password) == $pass && $active == 1;
}

// โค้ดโชว์รูปหน้าแรก

function findIMG($text){
   preg_match_all('/\[img\].*?\[\/img\]/i',$text,$page);
   foreach($page as $value)
      $src = substr($value[0],5);
   $src = substr($src,0,-6);
   return($src);
}

function ssi_pic($num_top = 12,$order,$board)
{
   global $context, $settings, $db_prefix, $txt, $scripturl, $ID_MEMBER, $user_info, $modSettings;
   // Find boards with lots of posts.
   $request = db_query("
      SELECT t.ID_TOPIC,m.body,m.subject
      FROM ({$db_prefix}topics as t , {$db_prefix}messages as m)
      WHERE t.ID_FIRST_MSG=m.ID_MSG AND t.ID_BOARD=$board
      ORDER BY t.".$order." DESC
      LIMIT $num_top", __FILE__, __LINE__);
   $topics = array();
   while ($row = mysql_fetch_assoc($request))
   {
      $topics[] = array(
         'id' => $row['ID_TOPIC'],
         'body' => $row['body'],
         'subject' => $row['subject']
      );
   }
   mysql_free_result($request);
   foreach ($topics as $data){
      $topic = "forum/?topic=".$data['id'];
      $srcPic = findIMG($data['body']);
      $subject = $data['subject'];
      echo '<div class="boxpGal">
         <div class="picpGal"><a href="'.$srcPic.'" title="คริกเพื่อดูภาพเต็ม."><img src="'.$srcPic.'" width="150" alt="" /></a></div><center>'.mb_substr($subject,0,25,'UTF-8').'</center>
         <div class="viewAllpic"><a href="'.$topic.'" target="_blank">More info</a></div>   
      </div>';
   }
}

?>

แล้วก็เอาโค้ดนี้ไปใส่ในไฟล์ BoardIndex.template.php ตรงที่ต้องการให้แสดง

อ้างถึงssi_pic(10,'ID_TOPIC',1);


ได้แล้วครับขอบคุณมากครับท่าน :wanwan017: :wanwan017: :wanwan017:

mymo


koclup1580

อ้างถึงจาก: mymo ใน 18 กรกฎาคม 2012, 12:07:12
อันนี้ v1 หรือ 2 ครับ
1 ครับ แตกมันโชว์

Fatal error: Cannot redeclare ssi_shutdown() (previously declared in C:\AppServ\www\webball\SSI.php:192) in C:\AppServ\www\webball\SSI.php on line 194

koclup1580

ดึง อัน 2 ไม่ได้เลย ต้องทำไงครับ

อยากโค๊ต ดึงรูป มาแสดงหน้าแรก และ โค๊ตดึงคลิปที่โพสในบอร์ด มาแสดง หน้าแรกด้วย ใครมีขอทีครับ V 2.0

ข้าวกระเพราหมู

ต้องเขียนcode เพิ่มเปล่า เคยเห็นหัวข้อนะ แต่รูปยังไม่เคยเห็น ครับ:wanwan031: :wanwan031:

koclup1580

อ้างถึงจาก: ข้าวกระเพราหมู ใน 31 กรกฎาคม 2012, 16:41:15
ต้องเขียนcode เพิ่มเปล่า เคยเห็นหัวข้อนะ แต่รูปยังไม่เคยเห็น ครับ:wanwan031: :wanwan031:

ใช่ครับ แต่ลองโค๊ดที่แจก มันไม่ขึ้น ของใครใช้ v 2 ขึ้นไปมี ก็ขอหน่อยนะครับ ทั้ง ดึงรูป และ ดึงวีดีโอ ส่วมมากจะเจอแต่ดึงรูปแต่ลองแล้วไม่ได้เลย ไม่รู้ผิดตรงไหน :-X