หัวข้อ: SMF หาคนช่วยโมงานลูกค้า 1500
เริ่มหัวข้อโดย: Madoo ที่ 30 กันยายน 2011, 13:38:54
หาคนช่วยโมงานให้ลูกค้าครับ ให้โม function ssi_recentAttachments สำหรับ smf ทั้งสองเวอรชั่นครับ -ให้ดึงแค่รูปแรกของหัวข้อนั้นๆ ตอนนี้มันดึงมาทุกรูป (รูปไฟล์แนบที่อัพจาก Browse.. ตอนตั้งกระทู้) -กำหนดอักษรของหัวข้อได้ -กำหนดไอดีบอร์ดได้ 1500 ทั้งสองเวอรชั่น ผมจัดเลเอ้าท์ได้ไม่มีปัญหาตรงนี้ครับ ส่วนอื่นๆ ที่ติดมากับโค๊ด ช่างมัน มาแบบรกๆ ก็ได้ ไม่ต้องจัดมาครับ หลังจากทำให้ผมแล้ว คุณจะเอามาแจกต่อก็ได้ไม่ว่ากันครับ ปล.ถ้าเป็นไปได้ ไว้ประสานงานกันก็ดีนะครับ อันไหนทำไม่ได้ ผมก็ส่งงานให้ทำต่อ อะไรอย่างนี้ บางอย่างโมไม่ได้เหมืิอนกัน ไม่ถนัดโม mod ถนัดตกแต่งมากกว่า ของ 1.1 จาก http://www.simplemachines.org/community/index.php?topic=193835.msg1341372#msg1341372 // Show the recent attachments. function ssi_recentAttachments($num_attachments = 8, $attachment_type = 'all', $output_method = 'echo') { global $db_prefix, $scripturl, $context, $txt, $func, $modSettings;
// Lets get the boards that we can view attachments on. $attachment_boards = boardsAllowedTo('view_attachments');
// Adios. if (empty($attachment_boards)) return array();
// Clause. $boards_clause = isset($attachment_boards[0]) ? '' : "AND t.ID_BOARD IN(" . implode(',', $attachment_boards) . ")";
// Now for the type of attachment. By default all attachments. switch ($attachment_type) { case 'images': $fileTypes = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'tiff'); break; case 'music': $fileTypes = array('mp3', 'wav', 'wma'); break; case 'videos': $fileTypes = array('wmv', 'mov', 'mpg', 'mpeg', 'avi'); break; case 'doc': $fileTypes = array('doc', 'pdf', 'txt'); break; case 'archive': $fileTypes = array('zip', 'tar', 'tar.gz', 'rar', '7z'); break; default: $fileTypes = array(); break; }
// Check to see if the extension is 4 chars long $ext = array(); foreach ($fileTypes as $type) $ext[] = "RIGHT(att.filename, " . strlen($type) . ") = '" . $type . "'";
// Make the clause for the query $filter_ext = empty($ext) ? '' : "AND (" . implode(' OR ', $ext) . ")";
$request = db_query($query = " SELECT att.ID_ATTACH, att.ID_MSG, att.filename, IFNULL(att.size, 0) AS filesize, att.downloads, mem.ID_MEMBER, IFNULL(mem.realName, m.posterName) AS posterName, m.ID_TOPIC, m.subject, t.ID_BOARD, m.posterTime, att.width, att.height, IFNULL(thumb.ID_ATTACH, 0) AS ID_THUMB, thumb.width AS thumb_width, thumb.height AS thumb_height FROM ({$db_prefix}attachments AS att, {$db_prefix}messages AS m, {$db_prefix}topics AS t) LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER) LEFT JOIN {$db_prefix}attachments AS thumb ON (thumb.ID_ATTACH = att.ID_THUMB) WHERE t.ID_TOPIC = m.ID_TOPIC AND att.ID_MSG = m.ID_MSG AND att.attachmentType = 0 $boards_clause $filter_ext ORDER BY att.ID_ATTACH DESC LIMIT $num_attachments", false, false);
$attachments = array(); $image_ids = array(); while ($row = mysql_fetch_assoc($request)) { $is_image = !empty($row['width']) && !empty($row['height']);
$attachments[$row['ID_ATTACH']] = array( 'member' => array( 'id' => $row['ID_MEMBER'], 'name' => $row['posterName'], 'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>', ), 'file' => array( 'filename' => $row['filename'], 'filesize' => round($row['filesize'] / 1024, 2) . $txt['smf211'], 'download' => $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $row['ID_ATTACH'], 'downloads' => $row['downloads'], 'is_image' => $is_image, ), 'topic' => array( 'id' => $row['ID_TOPIC'], 'ID_BOARD' => $row['ID_BOARD'], 'subject' => str_replace($txt['response_prefix'], '', $row['subject']), 'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#msg' . $row['ID_MSG'] . '">' . $func['ucwords'](strtolower($row['subject'])) . '</a>', 'time' => timeformat($row['posterTime']), ), );
// Image. if ($is_image) { $ID_THUMB = empty($row['ID_THUMB']) ? $row['ID_ATTACH'] : $row['ID_THUMB']; $attachments[$row['ID_ATTACH']]['file']['thumbnail'] = array( 'id' => $ID_THUMB, 'href' => $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $ID_THUMB . ';image', 'img' => '<img src="' . $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $ID_THUMB . ';image" />', 'width' => $row['width'], 'height' => $row['height'], 'link' => '<a href="' . $attachments[$row['ID_ATTACH']]['file']['download'] . '"><img src="' . $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $ID_THUMB . ';image" /></a>', ); $image_ids[] = $row['ID_ATTACH']; } } mysql_free_result($request);
// So you just want an array? Here you can have it. if ($output_method == 'array') return $attachments;
// Give them the default. echo ' <table class="ssi_table"> <tr> <th align="left">Attachment</th> <th align="left">Poster</th> <th align="left">Downloads</th> <th align="left">Filesize</th> </tr>'; foreach ($attachments as $attach) echo ' <tr> <td>', $attach['file']['thumbnail']['link'], '</td> <td>', $attach['member']['link'], '</td> <td>', $attach['file']['downloads'], '</td> <td>', $attach['file']['filesize'], '</td> </tr>'; echo ' </table>'; }
2.0 (มีมาอยู่แล้วในไฟล์) // We want to show the recent attachments outside of the forum. function ssi_recentAttachments($num_attachments = 10, $attachment_ext = array(), $output_method = 'echo') { global $smcFunc, $context, $modSettings, $scripturl, $txt, $settings;
// We want to make sure that we only get attachments for boards that we can see *if* any. $attachments_boards = boardsAllowedTo('view_attachments');
// No boards? Adios amigo. if (empty($attachments_boards)) return array();
// Is it an array? if (!is_array($attachment_ext)) $attachment_ext = array($attachment_ext);
// Lets build the query. $request = $smcFunc['db_query']('', ' SELECT att.id_attach, att.id_msg, att.filename, IFNULL(att.size, 0) AS filesize, att.downloads, mem.id_member, IFNULL(mem.real_name, m.poster_name) AS poster_name, m.id_topic, m.subject, t.id_board, m.poster_time, att.width, att.height' . (empty($modSettings['attachmentShowImages']) || empty($modSettings['attachmentThumbnails']) ? '' : ', IFNULL(thumb.id_attach, 0) AS id_thumb, thumb.width AS thumb_width, thumb.height AS thumb_height') . ' FROM {db_prefix}attachments AS att INNER JOIN {db_prefix}messages AS m ON (m.id_msg = att.id_msg) INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic) LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (empty($modSettings['attachmentShowImages']) || empty($modSettings['attachmentThumbnails']) ? '' : ' LEFT JOIN {db_prefix}attachments AS thumb ON (thumb.id_attach = att.id_thumb)') . ' WHERE att.attachment_type = 0' . ($attachments_boards === array(0) ? '' : ' AND m.id_board IN ({array_int:boards_can_see})') . (!empty($attachment_ext) ? ' AND att.fileext IN ({array_string:attachment_ext})' : '') . (!$modSettings['postmod_active'] || allowedTo('approve_posts') ? '' : ' AND t.approved = {int:is_approved} AND m.approved = {int:is_approved} AND att.approved = {int:is_approved}') . ' ORDER BY att.id_attach DESC LIMIT {int:num_attachments}', array( 'boards_can_see' => $attachments_boards, 'attachment_ext' => $attachment_ext, 'num_attachments' => $num_attachments, 'is_approved' => 1, ) );
// We have something. $attachments = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) { $filename = preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', htmlspecialchars($row['filename']));
// Is it an image? $attachments[$row['id_attach']] = array( 'member' => array( 'id' => $row['id_member'], 'name' => $row['poster_name'], 'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>', ), 'file' => array( 'filename' => $filename, 'filesize' => round($row['filesize'] /1024, 2) . $txt['kilobyte'], 'downloads' => $row['downloads'], 'href' => $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'], 'link' => '<img src="' . $settings['images_url'] . '/icons/clip.gif" alt="" /> <a href="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'] . '">' . $filename . '</a>', 'is_image' => !empty($row['width']) && !empty($row['height']) && !empty($modSettings['attachmentShowImages']), ), 'topic' => array( 'id' => $row['id_topic'], 'subject' => $row['subject'], 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>', 'time' => timeformat($row['poster_time']), ), );
// Images. if ($attachments[$row['id_attach']]['file']['is_image']) { $id_thumb = empty($row['id_thumb']) ? $row['id_attach'] : $row['id_thumb']; $attachments[$row['id_attach']]['file']['image'] = array( 'id' => $id_thumb, 'width' => $row['width'], 'height' => $row['height'], 'img' => '<img src="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'] . ';image" alt="' . $filename . '" />', 'thumb' => '<img src="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $id_thumb . ';image" alt="' . $filename . '" />', 'href' => $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $id_thumb . ';image', 'link' => '<a href="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'] . ';image"><img src="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $id_thumb . ';image" alt="' . $filename . '" /></a>', ); } } $smcFunc['db_free_result']($request);
// So you just want an array? Here you can have it. if ($output_method == 'array' || empty($attachments)) return $attachments;
// Give them the default. echo ' <table class="ssi_downloads" cellpadding="2"> <tr> <th align="left">', $txt['file'], '</th> <th align="left">', $txt['posted_by'], '</th> <th align="left">', $txt['downloads'], '</th> <th align="left">', $txt['filesize'], '</th> </tr>'; foreach ($attachments as $item) echo ' <tr> <td>', $item['file']['image']['link'], '</td> <td>', $attach['member']['link'], '</td> <td align="center">', $attach['file']['downloads'], '</td> <td>', $attach['file']['filesize'], '</td> </tr>'; echo ' </table>'; } P o r n t h e p T e a c h a n a v a k u l 81/36-37 Phacharat Rd,Taladkhwan Ampur Mueng,Nonthaburi 11000 Mail: teng-board.com @ hotmail.com Tel: 087 5 สาม สาม 6 8 สาม 6
หัวข้อ: Re: SMF หาคนช่วยโมงานลูกค้า 1500
เริ่มหัวข้อโดย: NightClub ที่ 30 กันยายน 2011, 16:25:59
ดูผ่านผ่าน ลองแก้ $num_attachments = 8, $attachment_type = 'all', $output_method = 'echo') { global $db_prefix, $scripturl, $context, $txt, $func, $modSettings; เป็น $num_attachments = 8, $attachment_type = 'all', $output_method = 'echo') { global $db_prefix, $scripturl, $context, $txt, $func, $modSettings; $num_attachments = 1;
หัวข้อ: Re: SMF หาคนช่วยโมงานลูกค้า 1500
เริ่มหัวข้อโดย: Madoo ที่ 30 กันยายน 2011, 17:21:12
ผมลืมแจ้งความต้องการอีกนิดครับ ถ้างั้นแจ้งเพิ่มเลยนะครับ ให้สามาถเีรียกฟังค์ชั่นเดียวกันมาแสดงได้หลายครั้ง หลายตำแหน่ง ในไฟล์เดียวกัน เช่น ตำแหน่งนี้ บอร์ด 1 ตำแหน่งนี้ บอร์ด 2 ไม่ไว้ตำแหน่งเดียวกัน แบบนี้ $attachment_boards = array(1 => 1, 2, 9); ปล.ขอโทษที่ตอบช้าครับ ตอนนี้มีคนติดต่อมา 3-4 คนแล้ว กำลังดูอยู่ครับผม ดูผ่านผ่าน ลองแก้ $num_attachments = 8, $attachment_type = 'all', $output_method = 'echo') { global $db_prefix, $scripturl, $context, $txt, $func, $modSettings; เป็น $num_attachments = 8, $attachment_type = 'all', $output_method = 'echo') { global $db_prefix, $scripturl, $context, $txt, $func, $modSettings; $num_attachments = 1;
ถ้าไอดีแก้ได้อยู่ครับผม แต่แบบดึงมาแค่รูปเดียว อันนี้มั่วอย่างไรก็ Error ทุกที
หัวข้อ: Re: SMF หาคนช่วยโมงานลูกค้า 1500
เริ่มหัวข้อโดย: PAGE ที่ 30 กันยายน 2011, 17:26:14
มาดูครับ
หัวข้อ: Re: SMF หาคนช่วยโมงานลูกค้า 1500
เริ่มหัวข้อโดย: SWOY ที่ 30 กันยายน 2011, 19:09:58
พีเอ็มไปละ :wanwan017:
หัวข้อ: Re: SMF หาคนช่วยโมงานลูกค้า 1500
เริ่มหัวข้อโดย: Madoo ที่ 30 กันยายน 2011, 19:19:07
พีเ็อ็มผมคลิกดูข้อความเข้าไม่ได้ครับ ดูได้แต่ข้อความมที่ส่งออก และต้องดูข้อความเข้าจากอีเมล์เอาครับ ต้องขอขอบคุณทุกท่านมากจริงๆ ที่ติดต่อเข้ามาครับผม ตอนนี้ได้คนแล้วครับ โอกาสหน้ามีงานอีกจะติดต่อคนที่เคยพีเอ็มติดต่อมาในครั้งนี้ครับผม
ขอบคุณอีกครั้งครับที่สนใจ
หัวข้อ: Re: SMF หาคนช่วยโมงานลูกค้า 1500
เริ่มหัวข้อโดย: parinya ที่ 01 ตุลาคม 2011, 04:15:53
อยากขอลองครับ เคยทำอยู่ แสดงเนื้อหา แยกบอร์ดประมาณว่า 1. เรื่องตลก ดึงมา 10 กระทู้แรกของเรื่องตลก 2. เรื่องเล่า ดึงมา 10 กระทู้แรก ของเรื่องเล่า
หัวข้อ: Re: SMF หาคนช่วยโมงานลูกค้า 1500
เริ่มหัวข้อโดย: xvlnw.com ที่ 01 ตุลาคม 2011, 05:04:42
อยากขอลองครับ เคยทำอยู่ แสดงเนื้อหา แยกบอร์ดประมาณว่า 1. เรื่องตลก ดึงมา 10 กระทู้แรกของเรื่องตลก 2. เรื่องเล่า ดึงมา 10 กระทู้แรก ของเรื่องเล่า
แบบนี้น่าจะลองดึงแบบเป็น rss ดูนะครับ
|