Advertisement:

Author Topic: Limit Recent Posts on BoardIndex to certain boards.  (Read 37690 times)

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Limit Recent Posts on BoardIndex to certain boards.
« on: July 19, 2006, 01:01:05 AM »
If you want to limit the recent posts on the board index this is how to do it.

In Recent.php find
Code: [Select]
$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

Code: [Select]
// 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 ,
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Offline Stuart

  • Full Member
  • ***
  • Posts: 421
Re: Limit Recent Posts on BoardIndex to certain boards.
« Reply #1 on: July 20, 2006, 02:41:19 PM »
This is very useful, thanks Jay  ;D

Offline Stüldt Håjt

  • Jr. Member
  • **
  • Posts: 326
Re: Limit Recent Posts on BoardIndex to certain boards.
« Reply #2 on: September 29, 2006, 08:12:00 AM »
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.

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: Limit Recent Posts on BoardIndex to certain boards.
« Reply #3 on: September 29, 2006, 11:20:23 AM »
Ok you can try this

Code: [Select]
$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__);
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Offline Stüldt Håjt

  • Jr. Member
  • **
  • Posts: 326
Re: Limit Recent Posts on BoardIndex to certain boards.
« Reply #4 on: September 29, 2006, 02:27:05 PM »
This comes with 1.1RC3. No mods installed..

Code: [Select]
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:

Code: [Select]
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

Code: [Select]
2: implode(): Bad arguments.
Tiedosto: /var/www/Sources/Recent.php
Rivi: 101

Code: [Select]
8: Undefined variable: board_to_hide
Tiedosto: /var/www/Sources/Recent.php
Rivi: 101
« Last Edit: September 29, 2006, 02:29:29 PM by Stüldt Håjt »

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: Limit Recent Posts on BoardIndex to certain boards.
« Reply #5 on: September 29, 2006, 02:35:12 PM »
Oops small typeo.

Code: [Select]
$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__);
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Offline Stüldt Håjt

  • Jr. Member
  • **
  • Posts: 326
Re: Limit Recent Posts on BoardIndex to certain boards.
« Reply #6 on: September 29, 2006, 03:52:47 PM »
Thanks alot. Works great!

Offline pisdoktor

  • Jr. Member
  • **
  • Posts: 241
  • Gender: Male
    • medical student's web site
Re: Limit Recent Posts on BoardIndex to certain boards.
« Reply #7 on: November 26, 2006, 10:30:14 PM »
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?
JoomlaTurkiye.net Web Admin - Joomla Support Specialist

Personal site: www.sonerekici.com

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: Limit Recent Posts on BoardIndex to certain boards.
« Reply #8 on: November 26, 2006, 10:32:24 PM »
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.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Offline Saku

  • Jr. Member
  • **
  • Posts: 305
  • Gender: Male
Re: Limit Recent Posts on BoardIndex to certain boards.
« Reply #9 on: January 10, 2007, 04:12:26 PM »

Offline ckgb

  • Jr. Member
  • **
  • Posts: 125
  • Gender: Male
Re: Limit Recent Posts on BoardIndex to certain boards.
« Reply #10 on: March 17, 2007, 03:43:32 PM »
I second the previous post.

Also how about the same for Recent topic list?

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: Limit Recent Posts on BoardIndex to certain boards.
« Reply #11 on: March 19, 2007, 08:55:32 AM »
Do a search.  I think someone posted how to do it.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Offline Vandetta

  • Newbie
  • *
  • Posts: 3
Re: Limit Recent Posts on BoardIndex to certain boards.
« Reply #12 on: August 15, 2009, 08:47:01 PM »
Oops small typeo.

Code: [Select]
$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?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,035
    • Arantor on GitHub
Re: Limit Recent Posts on BoardIndex to certain boards.
« Reply #13 on: September 21, 2009, 04:58:21 AM »
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?
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Offline rikmoncur

  • Semi-Newbie
  • *
  • Posts: 12
Re: Limit Recent Posts on BoardIndex to certain boards.
« Reply #14 on: June 17, 2011, 10:58:54 AM »
As Vandetta has asked, I too would like to know how to do this on SMF 2.0 Core theme

Offline retroturk

  • Newbie
  • *
  • Posts: 2
Re: Limit Recent Posts on BoardIndex to certain boards.
« Reply #15 on: January 12, 2014, 05:06:02 AM »
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...