News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Hide the content of [code] tags from guests

Started by Joker™, January 09, 2011, 12:29:47 PM

Previous topic - Next topic

Joker™

I was personally having the problem on my forum that people were posting links in code tag which was visible to guests, so as to overcome this problem we can now hide the whole data in code tag from guests.

To do so, you just have to make following edits;

In Themes\Default\Languages\Modification.english.php

Find:
?>

Add Before:
$txt['something'] = 'Only registered users can see contents.';
$txt['blabla'] = 'Please click here to <a target="_blank" href="' . $scripturl . '?action=register"">Register</a> or <a target="_blank" href="' . $scripturl . '?action=login">Login</a>';



In Sources/Subs.php

Find: 'tag' => 'code',
'type' => 'unparsed_content',
'content' => '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',


Replace it with:
'tag' => 'code',
'type' => 'unparsed_content',
'content' => $user_info['is_guest'] ? '<div class="codeheader">' . $txt['code'] . ': </div><code class="bbc_code">' . $txt['something'] . ' ' . $txt['blabla'] . '</code>' :  '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',



You can change text strings as you like.


This trick is available as mod also, here.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Illori

this might be better on the tips board. it is a nice idea for some forums.

tesser

arantor had a mod that works for RC3 but it also works on RC4  that did the  hide code  from guests  ;D lucky me i have it now his site is gone.

Joker™

Quote from: tesser on January 09, 2011, 01:07:43 PM
arantor had a mod that works for RC3 but it also works on RC4  that did the  hide code  from guests  ;D lucky me i have it now his site is gone.
I must have missed that mod.


For working demo of code above you can open any non-sticky post from this board.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Illori

might be slightly more professional to add a space in the code replacement
Only registered users can see contents.Please click here to Register or Login and replace with
Only registered users can see this content. Please click here to Register or Login.

Arantor

QuoteI must have missed that mod.

I did a mega version of the 'registered links' mod that did code tags as well, also provided the option to only hide links that aren't internal ones.

Joker™

Quote from: Illori on January 09, 2011, 01:20:53 PM
might be slightly more professional to add a space in the code replacement
Only registered users can see contents.Please click here to Register or Login and replace with
Only registered users can see this content. Please click here to Register or Login.
Thanks for the suggestion. Made the changes in above code regarding the space you have mentioned.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Joker™

Quote from: IncognitoMuse on January 09, 2011, 01:30:55 PM
QuoteI must have missed that mod.

I did a mega version of the 'registered links' mod that did code tags as well, also provided the option to only hide links that aren't internal ones.
Nice to see the biggest spammer back ;D.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Arantor

I wouldn't call it back, seeing how the support I'm doing is extremely limited, mostly to assess things that I think need to be fixed in SMF, and that none of the mods that were on arantormods.com are being published anywhere by me, in fact the only place to get them now is a paid site I gave them to, so they could sell the mods to folks.

Joker™

Quote from: IncognitoMuse on January 09, 2011, 01:36:20 PM
I wouldn't call it back, seeing how the support I'm doing is extremely limited, mostly to assess things that I think need to be fixed in SMF, and that none of the mods that were on arantormods.com are being published anywhere by me, in fact the only place to get them now is a paid site I gave them to, so they could sell the mods to folks.
Lol, I myself was busy like hell in past month, even missed to celebrate new year :-X.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Cowley

Thank you so much for your advice. Exactly what I was looking for!  ;)

Jeet Chowdhury

#11
Quote from: Joker™ on January 09, 2011, 12:29:47 PM
I was personally having the problem on my forum that people were posting links in code tag which was visible to guests, so as to overcome this problem we can now hide the whole data in code tag from guests.

To do so, you just have to make following edits;

In Themes\Default\Modification.english.php

Find:
?>

Add Before:
$txt['something'] = 'Only registered users can see contents.';
$txt['blabla'] = 'Please click here to <a target="_blank" href="' . $scripturl . '?action=register"">Register</a> or <a target="_blank" href="' . $scripturl . '?action=login">Login</a>';



In Sources/Subs.php

Find:            'tag' => 'code',
            'type' => 'unparsed_content',
            'content' => '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',


Replace it with:
            'tag' => 'code',
            'type' => 'unparsed_content',
            'content' => $user_info['is_guest'] ? '<div class="codeheader">' . $txt['code'] . ': </div><code class="bbc_code">' . $txt['something'] . ' ' . $txt['blabla'] . '</code>' :  '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',



You can change text strings as you like.

how to hide quote tag also?


also after login user backto forum index. how to log him back to where he is actually?

Matthew K.

The same way you would with the code tags...only for the quote tags.

Joker™

Quote from: Labradoodle-360 on February 01, 2011, 11:45:28 AM
The same way you would with the code tags...only for the quote tags.
That depends that how the data of quotes is being handled. I may take a look at the file in a bit.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Joker™

Lol hiding data in quotes seems to bit tricky as last night I was unable to find how that data is supplied in quotes tag, I will this thing a shot tonight for sure.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Arantor

You actually can't directly rewrite quote tags because the contents of the tag is never supplied to the parser (since it can contain other tags)

All you can do is what I used to do in my registered-links mod: rewrite the start and end tags in the validate function to something else, then strip them out in the obsess_rewrite buffer.

Joker™

Quote from: Arantor on February 02, 2011, 08:32:23 AM
You actually can't directly rewrite quote tags because the contents of the tag is never supplied to the parser (since it can contain other tags)
That's what I thought after seeing "Remove images from quotes tag" mod.


Quote
All you can do is what I used to do in my registered-links mod: rewrite the start and end tags in the validate function to something else, then strip them out in the obsess_rewrite buffer.
Umm that seems to be a bit above my head.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

steeltape

hi this is very useful mod for me and i'm grateful that you share this with us the leechers
however, there is no Themes\Default\Modification.english.php file in my default theme nor my other sub themes.
so how?

smf 2.0 rc5

mashby

Try one level down, so:
Themes/default/languages/Modifications.english.php
Always be a little kinder than necessary.
- James M. Barrie

Joker™

Quote from: mashby on May 24, 2011, 09:55:26 AM
Try one level down, so:
Themes/default/languages/Modifications.english.php
Thanks for pointing out the error ;).
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Advertisement: