Simple Machines Community Forum

SMF Development => Feature Requests => Applied or Declined Requests => Aiheen aloitti: forumposters - heinäkuu 15, 2006, 12:52:21 IP

Otsikko: Recent Posts - Admin Selects List of Boards and can Exclude Ad Boards
Kirjoitti: forumposters - heinäkuu 15, 2006, 12:52:21 IP
I'd like to be able to only show recent posts from a few boards and not others that only have ads in them.  This would increase the quality of the posts that recent posts displays.  Can this be done?
Otsikko: Re: Recent Posts - Admin Selects List of Boards and can Exclude Ad Boards
Kirjoitti: JayBachatero - heinäkuu 17, 2006, 02:40:45 AP
You mean something like this?
http://www.simplemachines.org/community/index.php?action=unread;boards=9,10
Otsikko: Re: Recent Posts - Admin Selects List of Boards and can Exclude Ad Boards
Kirjoitti: forumposters - heinäkuu 17, 2006, 02:56:25 IP
Yes, but I want those threads to display on the index or home page rather than just be a link that you have to click to view these threads.
Otsikko: Re: Recent Posts - Admin Selects List of Boards and can Exclude Ad Boards
Kirjoitti: JayBachatero - heinäkuu 17, 2006, 03:18:58 IP
You would have to modify the queries in BoardIndex.php to only get new replies from those boards.
Otsikko: Re: Recent Posts - Admin Selects List of Boards and can Exclude Ad Boards
Kirjoitti: forumposters - heinäkuu 17, 2006, 04:25:07 IP
Here's the related code in that file.  Can you give me some hints or pointers on how we could limit this just just a specific set of boards?

// This is the "Recent Posts" bar.
if (!empty($settings['number_recent_posts']))
{
echo '
<tr>
<td class="titlebg" colspan="2">', $txt[214], '</td>
</tr>
<tr>
<td class="windowbg" width="20" valign="middle" align="center">
<a href="', $scripturl, '?action=recent"><img src="', $settings['images_url'], '/post/xx.gif" alt="', $txt[214], '" /></a>
</td>
<td class="windowbg2">';

// Only show one post.
if ($settings['number_recent_posts'] == 1)
{
// latest_post has link, href, time, subject, short_subject (shortened with...), and topic. (its id.)
echo '
<b><a href="', $scripturl, '?action=recent">', $txt[214], '</a></b>
<div class="smalltext">
', $txt[234], ' &quot;', $context['latest_post']['link'], '&quot; ', $txt[235], ' (', $context['latest_post']['time'], ')<br />
</div>';
}
// Show lots of posts.
elseif (!empty($context['latest_posts']))
{
echo '
<table cellpadding="0" cellspacing="0" width="100%" border="0">';

/* Each post in latest_posts has:
board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
subject, short_subject (shortened with...), time, link, and href. */
foreach ($context['latest_posts'] as $post)
echo '
<tr>
<td class="middletext" valign="top" nowrap="nowrap"><b>', $post['link'], '</b> ', $txt[525], ' ', $post['poster']['link'], ' (', $post['board']['link'], ')</td>
<td class="middletext" align="right" valign="top" nowrap="nowrap">', $post['time'], '</td>
</tr>';
echo '
</table>';
}
echo '
</td>
</tr>';
}
Otsikko: Re: Recent Posts - Admin Selects List of Boards and can Exclude Ad Boards
Kirjoitti: JayBachatero - heinäkuu 17, 2006, 08:41:37 IP
In Recent.php find

$request = db_query("
SELECT
m.posterTime, m.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG,
IFNULL(mem.realName, m.posterName) AS posterName, t.ID_BOARD, b.name AS bName,
LEFT(m.body, 384) AS body, m.smileysEnabled
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
WHERE m.ID_MSG >= " . max(0, $modSettings['maxMsgID'] - 20 * $showlatestcount) . "
AND t.ID_TOPIC = m.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? "
AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
AND $user_info[query_see_board]
ORDER BY m.ID_MSG DESC
LIMIT $showlatestcount", __FILE__, __LINE__);


Replace with


// Board to show
$boards_to_show = array(6,7,16);

$request = db_query("
SELECT
m.posterTime, m.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG,
IFNULL(mem.realName, m.posterName) AS posterName, t.ID_BOARD, b.name AS bName,
LEFT(m.body, 384) AS body, m.smileysEnabled
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
WHERE m.ID_MSG >= " . max(0, $modSettings['maxMsgID'] - 20 * $showlatestcount) . "
AND t.ID_TOPIC = m.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? "
AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
AND $user_info[query_see_board]
AND (FIND_IN_SET(" . implode(', t.ID_BOARD) OR FIND_IN_SET(', $boards_to_show) . ", t.ID_BOARD))
ORDER BY m.ID_MSG DESC
LIMIT $showlatestcount", __FILE__, __LINE__);


Change $boards_to_show to the id of the boards that you want to show.  Separate each id with a ,
Otsikko: Re: Recent Posts - Admin Selects List of Boards and can Exclude Ad Boards
Kirjoitti: forumposters - heinäkuu 18, 2006, 03:23:02 IP
Perfect!