News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Hiding topic but display with direct link?

Started by pittu, April 15, 2015, 03:25:55 PM

Previous topic - Next topic

pittu

Say I want to hide a topic to be displayed in forum, but can be accessed directly. Possible?

thnx.

Kindred

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
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

margarett

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
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

pittu

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.

.

margarett

'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,
)
);
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

pittu

So this way I can exclude topics from 3 boards if I just add topic IDs?

thnx.

margarett

Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Advertisement: