Hi all,
I know that there is a special php block code for this functionality but that block lacks the "new" image and therefore I use the default recent topic block.
I found that the layout of this current topic block is in TPSubs.template.php
I changed this part of the code:
// leave out the recycle board, if any
if(isset($modSettings['recycle_board']))
$bb = array($modSettings['recycle_board']);
else
$bb = array();
into
// leave out the recycle board, if any
if(isset($modSettings['recycle_board']))
$bb = array(1);
else
$bb = array();
and now all topics in the "number 1" board are excluded.
Since I realy don't know if what I have done is correct coding and I also don't know what recycle boards are I wonder if - although it seems to work OK, I did something stupid?
I also changed the layout a bit!
Becuase I wanted to see some more of the subject line I changed in TPSubs.php line:
'short_subject' => shorten_subject($row['subject'], 25),
into
'short_subject' => shorten_subject($row['subject'], 65),
Best regards,
Fred
do you have a board where all deleted posts and topics go? if so that is the recycle board.
i have not tested but if it is looking for an array, you could just do
$bb = array($modSettings['recycle_board'],1,2,3,4);
that should work, i have not tested it though.
Good job, wildenborch!
Hi Illori,
Thank you very much for your reply.
Your code is indeed working so I have replaced mine with yours.
Fred
Illori,
I was too quick..... this code does not exclude the boards I want to exclude.
And the code I used ($bb = array(1,7); only exclude the first listed board.
Since board 1 is the board I want to exclude and I don't use the recycle board I can use this code but not if I want to exclude some more in the future.
Best regards,
Fred
try this?
// leave out the recycle board, if any
if(isset($modSettings['recycle_board']))
$bb = array($modSettings['recycle_board']);
else
$bb = array(1,7);
No that wasn't the trick either.
Well maybe Sayaka Maizono can create a nice recent topic block based upon the current functionality in TPSubs.template.php ;D
i think found the issue...
$what = tp_recentTopics($context['TPortal']['recentboxnum'], $bb, 'array'); find that in TPsubs.template.php
replace with this
$what = tp_recentTopics($context['TPortal']['recentboxnum'], $exclude_boards = array(1), 'array');
replace 1 with the board that you want to exclude.
Hi Illori,
This works for the board I want to exclude.
I also tried this with multiple boards but then only the first board is excluded.
BTW, do you know why the output part in the code that shows the recents topics without avatar is referring to ssi_recentTopics and the part that shows the avatar is referring to tp_recentTopics ?
Best regards.
Fred
then change the code to this
$what = tp_recentTopics($context['TPortal']['recentboxnum'], $exclude_boards = array(1,2,3,4), 'array');
i only had one board with topics... so i assume that should work out fine.
one shows the avatar the other does not. so TP modified the SSI code to have the avatar shown.
Illori,
I should have been more clearer. I meant that I tried your code with several board by adding these boards to the code. So I already changed your code as suggested by you in your last post. But it still only the exclude the first board. So boards 2,3,4 are still shown.
seems a TP bug. SSI got updated sometime ago and TP did not.
try to replace this function in TPSubs.php with the following
// Recent topic list: [board] Subject by Poster Date
function tp_recentTopics($num_recent = 8, $exclude_boards = null, $include_boards = null, $output_method = 'echo')
{
global $context, $scripturl, $user_info, $modSettings, $smcFunc;
global $context, $settings, $scripturl, $txt, $db_prefix, $user_info;
global $modSettings, $smcFunc;
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();
}
// Find all the posts in distinct topics. Newer ones will have higher IDs.
$request = $smcFunc['db_query']('substring', '
SELECT
m.poster_time, ms.subject, m.id_topic, m.id_member, m.id_msg, b.id_board, b.name AS board_name, t.num_replies, t.num_views,
IFNULL(mem.real_name, m.poster_name) AS poster_name, ' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . ', SUBSTRING(m.body, 1, 384) AS body, m.smileys_enabled, m.icon,
IFNULL(a.id_attach, 0) AS ID_ATTACH, a.filename, a.attachment_type as attachmentType, mem.avatar as avy
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_last_msg)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
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 = {int:current_member})
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:current_member})' : '') . '
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member)
WHERE t.id_last_msg >= {int:min_message_id}
' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . '
' . (empty($include_boards) ? '' : '
AND b.id_board IN ({array_int:include_boards})') . '
AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? '
AND t.approved = {int:is_approved}
AND m.approved = {int:is_approved}' : '') . '
ORDER BY t.id_last_msg DESC
LIMIT ' . $num_recent,
array(
'current_member' => $user_info['id'],
'include_boards' => empty($include_boards) ? '' : $include_boards,
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
'min_message_id' => $modSettings['maxMsgID'] - 35 * min($num_recent, 5),
'is_approved' => 1,
)
);
$posts = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br />' => '')));
if ($smcFunc['strlen']($row['body']) > 128)
$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
// Censor the subject.
censorText($row['subject']);
censorText($row['body']);
// Build the array.
$posts[] = array(
'board' => array(
'id' => $row['id_board'],
'name' => $row['board_name'],
'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['board_name'] . '</a>'
),
'topic' => $row['id_topic'],
'poster' => array(
'id' => $row['id_member'],
'name' => $row['poster_name'],
'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>',
'avatar' => $row['avy'] == '' ? ($row['ID_ATTACH'] > 0 ? '<img src="' . (empty($row['attachmentType']) ? $scripturl . '?action=dlattach;attach=' . $row['ID_ATTACH'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" class="recent_avatar" border="0" />' : '') : (stristr($row['avy'], 'http://') ? '<img src="' . $row['avy'] . '" alt="" class="recent_avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($row['avy'], ENT_QUOTES) . '" alt="" class="recent_avatar" border="0" />')
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 25),
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true, $row['poster_time']),
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#new',
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#new" rel="nofollow">' . $row['subject'] . '</a>',
// Retained for compatibility - is technically incorrect!
'new' => !empty($row['is_read']),
'is_new' => empty($row['is_read']),
'new_from' => $row['new_from'],
);
}
$smcFunc['db_free_result']($request);
return $posts;
}
then use the code that was already posted to add the $exclude_boards array to TPsubs.template.php
i think this should work as expected... i am confusing myself testing it out.
Hi Illori,
YES !!! This change did the trick!
Thank you so much!
Fred
great.
Illori,
Will the changed code in TPsubs.php be included in future releases?
If not I have to update my "what do I have to change after a new TP release" document.
Fred
if no issues are found yes it should be.
Quote from: illori on November 30, 2015, 10:26:28 PM
if no issues are found yes it should be.
Thanks Illori. What else does this affect if left as is, I mean other parts of TP? Just curious.
if left as is you cant really use the functions as it should be. most will never notice but cant hurt to fix/update.
Quote from: illori on November 30, 2015, 10:42:33 PM
if left as is you cant really use the functions as it should be. most will never notice but cant hurt to fix/update.
Thanks, and agreed. ;)