Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: pittu on April 15, 2015, 03:25:55 PM

Title: Hiding topic but display with direct link?
Post by: pittu on April 15, 2015, 03:25:55 PM
Say I want to hide a topic to be displayed in forum, but can be accessed directly. Possible?

thnx.
Title: Re: Hiding topic but display with direct link?
Post by: Kindred on April 15, 2015, 03:32:57 PM
put the topic in a child board - of which the parent board is not accessible by anyone...


of course, then, once users GET to that board, the rest of the messages would be visible...

basiclaly, there is no good way to do what you are asking. SMF has no way to control visibility of or access to individual messages
Title: Re: Hiding topic but display with direct link?
Post by: margarett on April 15, 2015, 04:02:21 PM
Well, that's what hacking code is for :P
The easiest way is to trick MessageIndex to skip a certain topic ID (best way is in the query that fetches the topics)

I can't give you the code now but I'll try to do it later. Nudge me if I forget :P
Title: Re: Hiding topic but display with direct link?
Post by: pittu on April 15, 2015, 09:55:31 PM
QuoteI can't give you the code now but I'll try to do it later. Nudge me if I forget

Thnx.

Topics (3 boards have 2 - 3 topics each not to display) don't show under that board but can be accessed by url.

.
Title: Re: Hiding topic but display with direct link?
Post by: margarett on April 17, 2015, 08:37:38 PM
'K, so...

Sources/MessageIndex.php
Find:
// Sequential pages are often not optimized, so we add an additional query.
Add before
$excluded_topics = array(14,15);
This will be the array of topics that you want to exclude from listings. Add as many as you want, separate them with commas as in the example above.

Then...
Find:
WHERE t.id_board = {int:current_board}' . (!$modSettings['postmod_active'] || $context['can_approve_posts'] ? '' : '
AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')') . '
ORDER BY ' . (!empty($modSettings['enableStickyTopics']) ? 'is_sticky' . ($fake_ascending ? '' : ' DESC') . ', ' : '') . $_REQUEST['sort'] . ($ascending ? '' : ' DESC') . '
LIMIT {int:start}, {int:maxindex}',
array(
'current_board' => $board,
'current_member' => $user_info['id'],
'is_approved' => 1,
'id_member_guest' => 0,
'start' => $start,
'maxindex' => $maxindex,
)
);

Replace with:
WHERE t.id_board = {int:current_board}' . (!$modSettings['postmod_active'] || $context['can_approve_posts'] ? '' : '
AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')') . '
AND t.id_topic NOT IN ({array_int:excluded_topics})
ORDER BY ' . (!empty($modSettings['enableStickyTopics']) ? 'is_sticky' . ($fake_ascending ? '' : ' DESC') . ', ' : '') . $_REQUEST['sort'] . ($ascending ? '' : ' DESC') . '
LIMIT {int:start}, {int:maxindex}',
array(
'current_board' => $board,
'current_member' => $user_info['id'],
'is_approved' => 1,
'id_member_guest' => 0,
'start' => $start,
'maxindex' => $maxindex,
'excluded_topics' => $excluded_topics,
)
);


Find:
WHERE ' . ($pre_query ? 't.id_topic IN ({array_int:topic_list})' : 't.id_board = {int:current_board}') . (!$modSettings['postmod_active'] || $context['can_approve_posts'] ? '' : '
AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')') . '
ORDER BY ' . ($pre_query ? 'FIND_IN_SET(t.id_topic, {string:find_set_topics})' : (!empty($modSettings['enableStickyTopics']) ? 'is_sticky' . ($fake_ascending ? '' : ' DESC') . ', ' : '') . $_REQUEST['sort'] . ($ascending ? '' : ' DESC')) . '
LIMIT ' . ($pre_query ? '' : '{int:start}, ') . '{int:maxindex}',
array(
'current_board' => $board,
'current_member' => $user_info['id'],
'topic_list' => $topic_ids,
'is_approved' => 1,
'find_set_topics' => implode(',', $topic_ids),
'start' => $start,
'maxindex' => $maxindex,
)
);

Replace with:
WHERE ' . ($pre_query ? 't.id_topic IN ({array_int:topic_list})' : 't.id_board = {int:current_board}') . (!$modSettings['postmod_active'] || $context['can_approve_posts'] ? '' : '
AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')') . '
AND t.id_topic NOT IN ({array_int:excluded_topics})
ORDER BY ' . ($pre_query ? 'FIND_IN_SET(t.id_topic, {string:find_set_topics})' : (!empty($modSettings['enableStickyTopics']) ? 'is_sticky' . ($fake_ascending ? '' : ' DESC') . ', ' : '') . $_REQUEST['sort'] . ($ascending ? '' : ' DESC')) . '
LIMIT ' . ($pre_query ? '' : '{int:start}, ') . '{int:maxindex}',
array(
'current_board' => $board,
'current_member' => $user_info['id'],
'topic_list' => $topic_ids,
'is_approved' => 1,
'find_set_topics' => implode(',', $topic_ids),
'start' => $start,
'maxindex' => $maxindex,
'excluded_topics' => $excluded_topics,
)
);
Title: Re: Hiding topic but display with direct link?
Post by: pittu on April 17, 2015, 09:33:07 PM
So this way I can exclude topics from 3 boards if I just add topic IDs?

thnx.
Title: Re: Hiding topic but display with direct link?
Post by: margarett on April 17, 2015, 09:46:14 PM
Yes ;)