Simple Hide BBC - Hide the Goodies from Lurkers

Started by xPandax, July 17, 2013, 01:19:49 PM

Previous topic - Next topic

xPandax



Simple Hide BBC - Hide the Goodies from Lurkers
(For SMF 2.0.x)
Mod by xPandax | Other Mods by xPandax




Features
This mod adds a "hide" BBC which can be used to hide the goodies from lurkers. This mod can be used to share contents like

1) PSN/XBL/Steam and other gaming related codes
2) Beta access codes
3) Discount coupons for online shopping websites
4) Gift Cards

and more such stuff like that. Only the members deserve access to such valuable content.

Using this "hide" BBC, entire post or selected content in a post can be hidden from guests. Guests and users who have not logged into the forum will see the following message,

Sorry, only registered users can see this content. Please Login or Register.


How-To
Just wrap the content within [hide][/hide] tags.


Supported Themes
Works on almost all the themes without any custom edits!


Supported SMF Versions
Tested on fresh installation of 2.0.4.


Supported Languages

  • English
  • Dutch
Translations to other languages are welcome. Please post them in this Support Thread for this Mod.


Support
If you need support with this mod, please use the Support Thread for this Mod.


Changelog
v1.0 - Initial release.



License

This is free and unencumbered mod released into the public domain. For more information, see http://unlicense.org/ or the accompanying UNLICENSE file.

barnaby jonez

Great mod, exactly what I was looking for since my community shares codes with each other. Will install right now.

barnaby jonez

It seems to not work with emoticons -- is this normal, and is it possible to allow this?

Example:

;) works by itself

[hide];)[/hide] only shows the text

Neo_TE

Quote from: barnaby jonez on July 17, 2013, 01:44:12 PM
Great mod, exactly what I was looking for since my community shares codes with each other. Will install right now.
Thank you very much. :)


Quote from: barnaby jonez on July 17, 2013, 01:54:18 PM
It seems to not work with emoticons -- is this normal, and is it possible to allow this?

Example:

;) works by itself

[hide];)[/hide] only shows the text

Yes, its normal. Everything will appear as text since nothing will be parsed inside the [hide] tags.

French

Quote from: xPandaxTranslations to other languages are welcome.
Modifications.dutch-utf8.php or Modifications.dutch.php
Dutch Translation
// Start Simple Hide BBC
$txt['bbc_hide'] = 'Inhoud voor Gastgebruikers verbergen';
$txt['bbc_hide_warning'] = 'Sorry, inhoud is alleen zichtbaar voor geregistreerde gebruikers. ';
$txt['bbc_hide_login'] = 'A.u.b <a href="' . $scripturl . '?action=login">Inloggen</a> of <a href="' . $scripturl . '?action=register">Registreren</a>.';
// End Simple Hide BBC
?>

Neo_TE

Quote from: French on August 10, 2013, 05:03:59 AM
Modifications.dutch-utf8.php or Modifications.dutch.php
Dutch Translation
// Start Simple Hide BBC
$txt['bbc_hide'] = 'Inhoud voor Gastgebruikers verbergen';
$txt['bbc_hide_warning'] = 'Sorry, inhoud is alleen zichtbaar voor geregistreerde gebruikers. ';
$txt['bbc_hide_login'] = 'A.u.b <a href="' . $scripturl . '?action=login">Inloggen</a> of <a href="' . $scripturl . '?action=register">Registreren</a>.';
// End Simple Hide BBC
?>


Thank you very much. Added it to the package. :)

CapnCoconuts

Well, it works like it's supposed to... except for one thing: for some reason, it also has the same effect as [nobbc] tags, in that no BBC within the tags are parsed.

... wait, this is normal?

Please, if people wanted to not have BBC parsed, they would use the no bbc tag. Giving your hide tag the same functionality makes it annoying to work with when you want to hide things you would put in BBC tags, like links and images.

Arantor

It would have to be completely rewritten and juggle with the vastly complex internals of the bbc parser to work the way you want it to work.
Holder of controversial views, all of which my own.


CapnCoconuts

Funny you should say that, because I decided to take matters in my own hands and got it to work perfectly by changing only one line.

Code (Subs.php) Select
'type' => 'unparsed_content',

Code (Subs.php, edited) Select
'type' => ($user_info['is_guest'] ? 'unparsed_content': null),

Arantor

Funny, that shouldn't actually work. But of course you know SMF better than I do.
Holder of controversial views, all of which my own.


CapnCoconuts

#10
Okay, how about a picture?

Heck, why not come to my forum and make an account yourself. Google "Fusion Fangaming." (Apparently new members here can't make outbound links...)

Neo_TE

Quote from: CapnCoconuts on August 24, 2013, 10:08:33 PM
Funny you should say that, because I decided to take matters in my own hands and got it to work perfectly by changing only one line.

Code (Subs.php) Select
'type' => 'unparsed_content',

Code (Subs.php, edited) Select
'type' => ($user_info['is_guest'] ? 'unparsed_content': null),

Well, thanks for that code. Ill check on that. :)

Neo_TE

#12
Quote from: CapnCoconuts on August 24, 2013, 10:08:33 PM
Funny you should say that, because I decided to take matters in my own hands and got it to work perfectly by changing only one line.

Code (Subs.php) Select
'type' => 'unparsed_content',

Code (Subs.php, edited) Select
'type' => ($user_info['is_guest'] ? 'unparsed_content': null),

Dude, that's awesome.



PS: I tried lots of stuff to make the content within [hide] tags to be parsed for registered users but I never thought of adding a test condition in the type of the content.

Neo_TE

Mod updated. All users are requested to upgrade to the new version.

v2.0 - Now all content inside [hide] tags will be parsed for users who are logged in.

Thanks to CapnCoconuts for the brilliant tip & code.

Shambles

Just something to think about...


array(
'tag' => 'hide',
===> 'type' => ($user_info['is_guest'] ? 'unparsed_content' : null),
'content' => ($user_info['is_guest'] ? '<span style="color: red;" class="bbc_color">' . $txt['bbc_hide_warning'] . '</span>' . $txt['bbc_hide_login'] : '$1'),
'block_level' => true,
'disabled_content' => '$1',
),


For guests, this works fine.


For members, these two errors are appearing by the dozen:



2291 $message = substr($message, 0, $pos) . "\n" . $tag['after'] . "\n" . substr($message, $pos2 + 1);
2292 $pos += strlen($tag['after']) + 2;
..
..
..
2562 $message = substr($message, 0, $pos) . "\n" . $tag['before'] . "\n" . substr($message, $pos1);
2563 $pos += strlen($tag['before']) - 1 + 2;




The 'before' and 'after' values for $tag aren't being set, the way you've set it up, which gives this comment some meaning...

Quote from: Arantor on August 24, 2013, 10:11:41 PM
Funny, that shouldn't actually work...

Neo_TE

Update 2.0 has been rolled back due to a bug.

If you did upgrade to v2.0, please uninstall it & install v1.0 which has been uploaded in the mod site. Sorry for the confusion.



Quote from: Shambles on September 08, 2013, 01:46:10 PM
For members, these two errors are appearing by the dozen:

Thank you very much for the feedback.

My mistake for not checking the log. Big fail in my part.  :-X



Quote from: Arantor on August 24, 2013, 10:11:41 PM
Funny, that shouldn't actually work...
Quote from: Shambles on September 08, 2013, 01:46:10 PM
The 'before' and 'after' values for $tag aren't being set, the way you've set it up, which gives this comment some meaning...

The SMF legend already predicted this bug even before implementing it. :o

Shambles

Simple enough "fix", though.

array(
'tag' => 'hide',
'type' => ($user_info['is_guest'] ? 'unparsed_content' : null),
'content' => ($user_info['is_guest'] ? '<span style="color: red;" class="bbc_color">' . $txt['bbc_hide_warning'] . '</span>' . $txt['bbc_hide_login'] : '$1'),
===> 'before' => '',
===> 'after' => '',
'block_level' => true,
'disabled_content' => '$1',
),

Neo_TE

Quote from: Shambles on September 08, 2013, 02:44:23 PM
Simple enough "fix", though.

'content' => ($user_info['is_guest'] ? '<span style="color: red;" class="bbc_color">' . $txt['bbc_hide_warning'] . '</span>' . $txt['bbc_hide_login'] : '$1'),
===> 'before' => '',
===> 'after' => '',

Thank you very much for posting this.

As per the comments (line 936) in Subs.php, content cannot be used along with "before & after". Either we can use content or "before & after".

Ill try to make changes to the mod by using "before & after" instead of content.

gomzy

i cannot use bbcode hide and color ... please help im using smf 2.0

[hide][color=red]test[/color][/hide]

Neo_TE

Sorry, other BBC codes won't work inside hide tags. All content inside hide tags will appear as plain text.

Advertisement: