If you want to limit the recent posts on the board index this is how to do it.
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 (FIND_IN_SET(" . implode(', t.ID_BOARD) OR FIND_IN_SET(', $boards_to_show) . ", t.ID_BOARD))
AND $user_info[query_see_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 ,
This is very useful, thanks Jay ;D
Is it possible to change so I can limit boards not to show? It would be much easier to limit this one board to not to show posts. So when I create a new board I don't have to edit this.
Ok you can try this
$boards_to_hide = 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 t.ID_BOARD NOT IN (" . implode(',', $board_to_hide) . ")
AND $user_info[query_see_board]
ORDER BY m.ID_MSG DESC
LIMIT $showlatestcount", __FILE__, __LINE__);
This comes with 1.1RC3. No mods installed..
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')
AND 1
ORDER BY m.ID_MSG DESC
LIMIT 5' at line 11
Tiedosto: /var/www/Sources/Recent.php
Rivi: 104
And in error log:
Tietokantavirhe: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')
AND (FIND_IN_SET(0, b.memberGroups) OR FIND_IN_SET(6, b.me
Tiedosto: /var/www/Sources/Recent.php
Rivi: 104
2: implode(): Bad arguments.
Tiedosto: /var/www/Sources/Recent.php
Rivi: 101
8: Undefined variable: board_to_hide
Tiedosto: /var/www/Sources/Recent.php
Rivi: 101
Oops small typeo.
$boards_to_hide = 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 t.ID_BOARD NOT IN (" . implode(',', $boards_to_hide) . ")
AND $user_info[query_see_board]
ORDER BY m.ID_MSG DESC
LIMIT $showlatestcount", __FILE__, __LINE__);
Thanks alot. Works great!
good works ;) but i want to add time limit. (for example: recent post in last 12 hours, recent posts in today, recent post in yesterday, recent post last week...) what do you do?
Well it wouldn't be as simple as this one but it can be done. I'll add it to my mod todo list. Mind you it's a VERY long list so I might not do this one right away.
How to do the same on unread posts
http://www.simplemachines.org/community/index.php?action=unread
I second the previous post.
Also how about the same for Recent topic list?
Do a search. I think someone posted how to do it.
Zitat von: JayBachatero in September 29, 2006, 02:35:12 NACHMITTAGS
Oops small typeo.
$boards_to_hide = 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 t.ID_BOARD NOT IN (" . implode(',', $boards_to_hide) . ")
AND $user_info[query_see_board]
ORDER BY m.ID_MSG DESC
LIMIT $showlatestcount", __FILE__, __LINE__);
I'm a bit of a script kiddie. How do I get this working on SMF 2.0 since the code is different. I spent hours reading though stuff I used notepad++ to see that you added
$boards_to_hide = array(6,7,16);
AND t.ID_BOARD NOT IN (" . implode(',', $boards_to_hide) . ")
This is exactly what I want to do. I'd like to hide or exclude only one board from recent posts. I understand (6,7,16) refers to 3 boards and that I'd only have to ad one board id there. Where do I add it in SMF 2.0 though?
Is this still an issue for you, Vandetta? This may have been covered in another thread for 2.0 by now, but if not what exactly do you want to hide from where?
As Vandetta has asked, I too would like to know how to do this on SMF 2.0 Core theme
Great little mod...Thanks a lot...I looked for this ages...thanks
ps. I want to show topics intead of posts on recent posts section, but I hope I can solve that...