Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 4255
Latest: andreios
New This Month: 3
New This Week: 1
New Today: 0
Stats
Total Posts: 43260
Total Topics: 7518
Most Online Today: 297
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 1
Guests: 276
Total: 277

Author Topic: Converting 1.x ssi_recentTopics to include "$include_boards"  (Read 2538 times)

0 Members and 1 Guest are viewing this topic.

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Converting 1.x ssi_recentTopics to include "$include_boards"
« on: February 24, 2016, 02:45:35 pm »
Here's the original ssi_recentTopics function found in SSI.php for SMF 1.x

// Recent topic list:   [board] Subject by Poster
	
Date
function ssi_recentTopics($num_recent 8$exclude_boards null$output_method 'echo')
{
	
global 
$context$settings$scripturl$txt$db_prefix$ID_MEMBER;
	
global 
$user_info$modSettings$func;

	
if (
$exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
	
	
$exclude_boards = array($modSettings['recycle_board']);
	
else
	
	
$exclude_boards = empty($exclude_boards) ? array() : $exclude_boards;

	
$stable_icons = array('xx''thumbup''thumbdown''exclamation''question''lamp''smiley''angry''cheesy''grin''sad''wink''moved''recycled''wireless');
	
$icon_sources = array();
	
foreach (
$stable_icons as $icon)
	
	
$icon_sources[$icon] = 'images_url';

	
// Find all the posts in distinct topics.  Newer ones will have higher IDs.
	
$request db_query("
	
	
SELECT
	
	
	
m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName,
	
	
	
IFNULL(mem.realName, m.posterName) AS posterName, " 
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' '
	
	
	
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
	
	
	
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from'
) . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon
	
	
FROM (
{$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
	
	
	
LEFT JOIN 
{$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
	
	
	
LEFT JOIN 
{$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
	
	
	
LEFT JOIN 
{$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" '') . "
	
	
WHERE t.ID_LAST_MSG >= " 
. ($modSettings['maxMsgID'] - 35 min($num_recent5)) . "
	
	
	
AND t.ID_LAST_MSG = m.ID_MSG
	
	
	
AND b.ID_BOARD = t.ID_BOARD" 
. (empty($exclude_boards) ? '' "
	
	
	
AND b.ID_BOARD NOT IN (" 
implode(', '$exclude_boards) . ")") . "
	
	
	
AND 
$user_info[query_see_board]
	
	
	
AND ms.ID_MSG = t.ID_FIRST_MSG
	
	
ORDER BY t.ID_LAST_MSG DESC
	
	
LIMIT 
$num_recent"__FILE____LINE__);


Here's what I've done; this code was inspired by ssi_recentTopics found in SSI.php in SMF 2.x...

function ssi_recentTopics($num_recent 8$exclude_boards null$include_boards null$output_method 'echo')
{
	
global 
$context$settings$scripturl$txt$db_prefix$ID_MEMBER;
	
global 
$user_info$modSettings$func;

	
if (
$exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
	
	
$exclude_boards = array($modSettings['recycle_board']);
	
else
	
	
$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));

	
// Only some boards?.
	
if (
is_array($include_boards) || (int) $include_boards === $include_boards)
	
{
	
	
$include_boards is_array($include_boards) ? $include_boards : array($include_boards);
	
}
	
elseif (
$include_boards != null)
	
{
	
	
$output_method $include_boards;
	
	
$include_boards = array();
	
}
	

	
$stable_icons = array('xx''thumbup''thumbdown''exclamation''question''lamp''smiley''angry''cheesy''grin''sad''wink''moved''recycled''wireless');
	
$icon_sources = array();
	
foreach (
$stable_icons as $icon)
	
	
$icon_sources[$icon] = 'images_url';

	
// Find all the posts in distinct topics.  Newer ones will have higher IDs.
	
$request db_query("
	
	
SELECT
	
	
	
m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName, t.numReplies, t.numViews,
	
	
	
IFNULL(mem.realName, m.posterName) AS posterName, " 
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' '
	
	
	
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
	
	
	
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from'
) . ", LEFT(m.body, 384) AS body, m.smileysEnabled, ms.icon
	
	
FROM (
{$db_prefix}messages AS m, {$db_prefix}boards AS b)
        INNER JOIN 
{$db_prefix}topics AS t ON (t.ID_LAST_MSG = m.ID_MSG)
        INNER JOIN 
{$db_prefix}messages AS ms ON (ms.ID_MSG = t.ID_FIRST_MSG)
	
	
	
LEFT JOIN 
{$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
	
	
	
LEFT JOIN 
{$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
	
	
	
LEFT JOIN 
{$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" '') . "
	
	
WHERE b.ID_BOARD = t.ID_BOARD
	
	
	

	
	
	
. (empty($exclude_boards) ? '' "
	
	
	
AND b.ID_BOARD NOT IN (" 
implode(', '$exclude_boards) . ")") . "
	
	
	

	
	
	
. (empty($include_boards) ? '' "
	
	
	
AND b.ID_BOARD IN (" 
implode(', '$include_boards) . ")") . "
	
	
	
	
	
	

	
	
	
AND t.numReplies < 25
	
	
	
AND 
$user_info[query_see_board]
	
	
ORDER BY t.ID_LAST_MSG DESC
	
	
LIMIT 
$num_recent"__FILE____LINE__);


I'm finding that the $exclude_boards is working fine when adding the function to a template, but when I use $include_boards, it just shows the most recent topics including those found in the recycling bin...

Why? Please help :-\

http://support.simplemachines.org/function_db/index.php?action=view_function;id=515;sa=viewall
« Last Edit: February 24, 2016, 02:58:10 pm by shuban »

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: Converting 1.x ssi_recentTopics to include "$include_boards"
« Reply #1 on: February 24, 2016, 10:09:21 pm »
is $exclude_boards  null or are you passing something else to it
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: Converting 1.x ssi_recentTopics to include "$include_boards"
« Reply #2 on: February 24, 2016, 10:23:20 pm »
When I'm calling out the function inside a template for example, I don't include the $exclude_boards variable. Should I? I mean I thought it was a null variable.

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: Converting 1.x ssi_recentTopics to include "$include_boards"
« Reply #3 on: February 24, 2016, 10:36:30 pm »
Just be sure you set it to null
That should force it to include the recycle bin check
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: Converting 1.x ssi_recentTopics to include "$include_boards"
« Reply #4 on: February 24, 2016, 10:50:58 pm »
That did it...

Thank you

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: Converting 1.x ssi_recentTopics to include "$include_boards"
« Reply #5 on: February 24, 2016, 10:53:26 pm »
Glad to help
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

 

Related Topics

  Subject / Started by Replies Last post
1 Replies
4415 Views
Last post May 21, 2007, 06:37:59 pm
by SMFHacks
1 Replies
8882 Views
Last post September 28, 2007, 11:46:07 am
by smalldonkey
2 Replies
8183 Views
Last post November 06, 2007, 08:55:18 pm
by dry3210
1 Replies
6576 Views
Last post March 26, 2011, 01:26:09 pm
by SMFHacks
8 Replies
8286 Views
Last post September 19, 2011, 02:00:29 pm
by VividViews

+- Recent Topics

No thumbnails on new uploads by Tonyvic
Today at 06:26:18 am

Display the Contact Page for guests by SMFHacks
March 27, 2024, 10:55:43 am

is it possible to add support for odysee.com by fvlog19
March 21, 2024, 08:47:51 am

Request for admin notification by davejo
March 10, 2024, 01:31:59 am

I need help with torrent upload by Ineedsmfhelp
March 09, 2024, 10:01:13 pm

an idea for new mod (( content type with different display )) by SMFHacks
February 27, 2024, 01:36:27 pm

[Mod] RSS Feed Poster by SMFHacks
February 27, 2024, 11:57:18 am

find duplicate pictures by fvlog19
February 14, 2024, 02:22:40 pm

Error uploading video. by SMFHacks
February 08, 2024, 02:04:16 pm

Gallery icon as last added image by fvlog19
February 01, 2024, 01:04:56 pm

Powered by EzPortal