Index.php
Find
// Board is not empty... topic is not empty... action is empty.. Display!
else
{
require_once($sourcedir . '/Display.php');
return 'Display';
}
Replace with
// Board is not empty... topic is not empty... action is empty.. Display!
elseif(!empty($topic) && $context['user']['is_logged'])
{
require_once($sourcedir . '/Display.php');
return 'Display';
}
elseif(!empty($topic) && !$context['user']['is_logged']) {
require $sourcedir . '/LogInOut.php';
return 'Login';
}
And change
global $modSettings, $settings, $user_info, $board, $topic, $board_info, $maintenance, $sourcedir
To
global $modSettings, $settings, $user_info, $board, $topic, $board_info, $maintenance, $sourcedir, $context
Not heavily tested but should work :) Actually it shows the login page rather than redirecting, but it has the same effect.
I have also packaged this in a mod and submitted this to the mod site. :)
Good, very good trick.
Thank you.
Very helpful. Thanks!
I'm just curious, what is the difference between Hide Topics from Guests (http://custom.simplemachines.org/mods/index.php?mod=2380) and this trick?
You're welcome :)
@Phantomm: this mod has a very small difference in functionality. This mod just shows a login page when a guest tries to read topics. Hide Topics from Guests is a more advanced mod. :P
Just wondering though, does anyone have problems with this trick? I haven't got problems with it myself, but I was told that admins can't see topics either. =/ Doesn't happen to me though
thanks i hade the same question
You're welcome :)
and what if I want redirect guests to the login page only in selected boards?
is there any way to do this?
Yup, but it would require a few extra edits. I'm quite busy with other stuff right now, but I will look into it when I have some time. :)
thanks ;)
Thanks but already a mod is there. "Look but no read".
Quote from: 医生唱片骑师 on April 15, 2012, 12:17:18 PM
And change
global $modSettings, $settings, $user_info, $board, $topic, $board_info, $maintenance, $sourcedir
To
global $modSettings, $settings, $user_info, $board, $topic, $board_info, $maintenance, $sourcedir, $context
Not heavily tested but should work :) Actually it shows the login page rather than redirecting, but it has the same effect.
I not find this line! Can anyone tell me what file I find?
I did have searched in index.php and I not found nothing there... :(
You can find that in the index.php in the root of your forum (there are multiple index.php, each directory has one :P). ;) Also, I'm planning to release an updated version soon (Thanks Labradoodle :) ). ;D
u sir is ae pure genius,
i have searched for this kind of - S aech ai Tee - for 5 hours straigh, i can't feel ma eyes.
then suddenly this topic comes up; thanks dude.
and for your information posters, all the packages u provided aren't working anymore / deleted or just drown; this one right here, this trick is working like ae boss in my latest SMF release.
respect earned
*GTA SA theme song playing* ill add u
[edit]tt removed -- Illori
Haha, glad you finally found it :)