0 Members and 1 Guest are viewing this topic.
then i guess the script will only work with 1 category or all categories.
$category = 0;
$exclude = array(12, 5, 3);
global $txt, $user_info, $settings, $memberContext, $scripturl, $boardurl, $smcFunc;// Configuration...// Percentage width of avatar area$avatararea = 30;// Colour of border around avatar$avbordercol= '#fff';// Default width and height of avatar$avwidth = 35;$avheight= 35;// Path to 'no avatar' image.$noavatarurl = $boardurl . '/Themes/default/images/noavatar.jpg';// If you want to limit it to one category, enter the category number here// If you want to use all categories, set it to 0. If you want to exclude cats below set this to zero too.$category = 0 ;// Exclude categories ? Use the category ids eg. $exclude = array(3,6);// Also set $category above to 0 (zero) for this to work.$exclude = array();// Set how many posts you want to display$limit = 5;// If you want to limit the number of characters displayed, enter the length here// If you want the whole post to be displayed, no matter what the length, set it to 0$maxlength = 1000;loadLanguage('Stats');$result = $smcFunc['db_query']('', " SELECT m.id_board, m.icon, m.subject, m.body, IFNULL(mem.real_name, m.poster_name) AS poster_name, m.poster_time, t.num_replies, t.id_topic, m.id_member, m.smileys_enabled, m.id_msg, t.locked FROM ({db_prefix}topics AS t, {db_prefix}messages AS m, {db_prefix}boards as b) LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member) WHERE m.id_msg = t.id_first_msg AND b.id_board = m.id_board AND $user_info[query_see_board]" . ($category > 0 ? " AND id_cat = {int:cat}" : "") . (!empty($exclude) ? " AND id_cat NOT IN ({array_int:exclude})" : "") . " ORDER BY RAND() LIMIT {int:limit}", array( 'exclude' => $exclude, 'cat' => $category, 'limit' => $limit) );while ($row = $smcFunc['db_fetch_assoc']($result)){ if ($maxlength > 0 && strlen($row['body']) > $maxlength) { $row['body'] = substr($row['body'], 0, $maxlength); while (substr($row['body'],-1) <> ' ') $row['body'] = substr($row['body'],0,-1); $row['body'] .= ' ...'; } // Get the avatar and build the image link for it, if it exists... $memberID = $row['id_member']; loadMemberData($memberID); loadMemberContext($memberID); if (!empty($memberContext[$memberID]['avatar']['href'])) { $news['avatar'] = '<img width="' . $avwidth . '" height="' . $avheight . '" style="border:1px solid ' . $avbordercol . ' ;padding: 2px" alt="' . $row['poster_name'] . '" title="' . $row['poster_name'] . '" src="' . $memberContext[$memberID]['avatar']['href'] . '" />'; } else { $news['avatar'] = '<img width="' . $avwidth . '" height="' . $avheight . '" style="border:1px solid ' . $avbordercol . ' ;padding: 2px" alt="' . $row['poster_name'] . '" title="' . $row['poster_name'] . '" src="' . $noavatarurl . '" />'; } $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); // Check that this message icon is there... if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']])) $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url'; censorText($row['subject']); censorText($row['body']); $news['icon'] = '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />'; $news['subject'] = $row['subject']; $news['time'] = timeformat($row['poster_time']); $news['body'] = $row['body']; $news['href'] = $scripturl . '?topic=' . $row['id_topic'] . '.0'; $news['link'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['num_replies'] . ' ' . ($row['num_replies'] == 1 ? $txt['ssi_comment'] : $txt['ssi_comments']) . '</a>'; $news['comment_link'] = !empty($row['locked']) ? '' : '<a href="' . $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . ';num_replies=' . $row['num_replies'] . '">' . $txt['ssi_write_comment'] . '</a>'; $news['poster'] = !empty($row['id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>' : $row['poster_name']; $news['locked'] = !empty($row['locked']); // Display it all...try your own styling. Might be better in a table. echo ' <div style="width:100%;display:table"> <div style="width: ' , $avatararea , '%;float:left;text-align:center"> ' , $news['avatar'] , ' </div> <div style="width: ' , 99 - $avatararea , '%;float:right"> <a href="', $news['href'], '">', $news['icon'], '</a> <strong>', $news['subject'], '</strong> <div class="smaller">', $news['time'], '<br />' , $txt['by'] , ' ' , $news['poster'], '</div> </div> <div class="post" style="padding: 2ex 0;clear:both">', $news['body'], '</div> ', $news['link'], $news['locked'] ? '' : ' | ' . $news['comment_link'], '<hr /> </div>'; }$smcFunc['db_free_result']($result);
global $txt, $user_info, $settings, $memberContext, $scripturl, $boardurl, $smcFunc;// Configuration...// Percentage width of avatar area$avatararea = 8;// Colour of border around avatar$avbordercol= '#fff';// Default width and height of avatar$avwidth = 35;$avheight= 35;// Path to 'no avatar' image.$noavatarurl = $boardurl . '/Themes/default/images/noavatar.jpg';// If you want to limit it to one category, enter the category number here// If you want to use all categories, set it to 0. If you want to exclude cats below set this to zero too.$category = 0 ;// Exclude categories ? Use the category ids eg. $exclude = array(3,6);// Also set $category above to 0 (zero) for this to work.$exclude = array(54,40,13,43,47,14,38,86,19,83,61,30,34,16,32,17,28,53,41,8,44,48,9,39,45,85,18,82,60,29,35,11,31,10,26,64,59,65,66,77,78,67,68,84,69,81,70,71,72,73,74,75,76);// Set how many posts you want to display$limit = 1;// If you want to limit the number of characters displayed, enter the length here// If you want the whole post to be displayed, no matter what the length, set it to 0$maxlength = 1000;loadLanguage('Stats');$result = $smcFunc['db_query']('', " SELECT m.id_board, m.icon, m.subject, m.body, IFNULL(mem.real_name, m.poster_name) AS poster_name, m.poster_time, t.num_replies, t.id_topic, m.id_member, m.smileys_enabled, m.id_msg, t.locked FROM ({db_prefix}topics AS t, {db_prefix}messages AS m, {db_prefix}boards as b) LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member) WHERE m.id_msg = t.id_first_msg AND b.id_board = m.id_board AND $user_info[query_see_board]" . ($category > 0 ? " AND id_cat = {int:cat}" : "") . (!empty($exclude) ? " AND id_cat NOT IN ({array_int:exclude})" : "") . " ORDER BY RAND() LIMIT {int:limit}", array( 'exclude' => $exclude, 'cat' => $category, 'limit' => $limit) );while ($row = $smcFunc['db_fetch_assoc']($result)){ if ($maxlength > 0 && strlen($row['body']) > $maxlength) { $row['body'] = substr($row['body'], 0, $maxlength); while (substr($row['body'],-1) <> ' ') $row['body'] = substr($row['body'],0,-1); $row['body'] .= ' ...'; } // Get the avatar and build the image link for it, if it exists... $memberID = $row['id_member']; loadMemberData($memberID); loadMemberContext($memberID); if (!empty($memberContext[$memberID]['avatar']['href'])) { $news['avatar'] = '<img width="' . $avwidth . '" height="' . $avheight . '" style="border:1px solid ' . $avbordercol . ' ;padding: 2px" alt="' . $row['poster_name'] . '" title="' . $row['poster_name'] . '" src="' . $memberContext[$memberID]['avatar']['href'] . '" />'; } else { $news['avatar'] = '<img width="' . $avwidth . '" height="' . $avheight . '" style="border:1px solid ' . $avbordercol . ' ;padding: 2px" alt="' . $row['poster_name'] . '" title="' . $row['poster_name'] . '" src="' . $noavatarurl . '" />'; } $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); // Check that this message icon is there... if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']])) $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url'; censorText($row['subject']); censorText($row['body']); $news['icon'] = '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />'; $news['subject'] = $row['subject']; $news['time'] = timeformat($row['poster_time']); $news['body'] = $row['body']; $news['href'] = $scripturl . '?topic=' . $row['id_topic'] . '.0'; $news['link'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['num_replies'] . ' ' . ($row['num_replies'] == 1 ? $txt['ssi_comment'] : $txt['ssi_comments']) . '</a>'; $news['comment_link'] = !empty($row['locked']) ? '' : '<a href="' . $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . ';num_replies=' . $row['num_replies'] . '">' . $txt['ssi_write_comment'] . '</a>'; $news['poster'] = !empty($row['id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>' : $row['poster_name']; $news['locked'] = !empty($row['locked']); // Display it all...try your own styling. Might be better in a table. echo ' <div style="width:100%;display:table"> <div style="width: ' , $avatararea , '%;float:left;text-align:center"> ' , $news['avatar'] , ' </div> <div style="width: ' , 99 - $avatararea , '%;float:right"> <a href="', $news['href'], '">', $news['icon'], '</a> <strong>', $news['subject'], '</strong> <div class="smaller">', $news['time'], '<br />' , $txt['by'] , ' ' , $news['poster'], '</div> </div> <div class="post" style="padding: 2ex 0;clear:both">', $news['body'], '</div> ', $news['link'], $news['locked'] ? '' : ' | ' . $news['comment_link'], '<hr /> </div>'; }$smcFunc['db_free_result']($result);
are you entering the numbers for the CATEGORIES or the numbers for the BOARDS. you need to make sure they are the id numbers for the CATEGORIES, if you have a category with both public and private boards in it, then you need to exclude that CATEGORY.
Thanks a lot men!!