Show BBCode content to guests

Started by emanuele, February 11, 2011, 11:55:19 AM

Previous topic - Next topic

emanuele

Link to Mod

This mod gives the possibility to hide or show the content of BBC tags to guests.

Going to: admin > forum > posts and topics > Bulletin Board Code it is possible to select which BBC tags show (or hide) to guests.

If a tag is set to be kept hidden to guests then a warning suggesting to login or register is prompted instead of the content of the tag.

Change log

  • 0.1.7: fixed undefined error due to the change of revision 0.1.6
  • 0.1.6: now keeps the formatting of the used tag (with few exceptions like url) and hides only the content
  • 0.1.5: updated compatibility
  • 0.1.4: if bbcodes were added with hooks after this modification was installed weren't listed in the bbcode page as expected
  • 0.1.3:
  • 0.1.2: updated to SMF 2.0 RC5
  • 0.1.1: initial release


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

jaisi

i have install this mod but it's not working, where can i found that hide tag setting ??

emanuele

Sorry for the late reply...

In the same page where you can enable BBCode tags: admin -> forum -> posts and topics -> Bulletin Board Code
At the end of the page you can find a table with the list of all the BBCodes available and you deselect those you don't want to show to guests...anyway you are right: I should have written some instructions... :-[


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

pizad_sura


emanuele

Guests can still see the content of bbcodes?
Or you don't see any option in the admin page?


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Jeet Chowdhury

i get error in rc5:

Find[Select]
foreach ($codes as $code) { // If we are not doing every tag only do ones we are interested in. if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) $bbc_codes[substr($code['tag'], 0, 1)][] = $code;

Replace[Select]

if(isset($modSettings['hiddenBBC'])) $hiddenBBC = explode(',', $modSettings['hiddenBBC']); foreach ($codes as $code) { if(isset($hiddenBBC) && in_array($code['tag'], $hiddenBBC) && $user_info['is_guest']){ $code['type'] = isset($code['type']) ? $code['type'] : 'unparsed_content'; switch ($code['type']){ case 'unparsed_equals': case 'unparsed_equals_content': case 'parsed_equals': $code['type'] = 'unparsed_equals_content'; break; case 'unparsed_content': case 'closed': $code['type'] = $code['type']; break; case 'unparsed_commas': case 'unparsed_commas_content': $code['type'] = 'unparsed_commas_content'; break; } $code['content'] = '<div style="display:block">' . $txt['mod_not_allowed_see'] . ' ' . $txt['login_or_register'] . '</div>'; unset($code['test']); unset($code['disabled_content']); unset($code['disabled_before']); unset($code['disabled_after']); unset($code['block_level']); unset($code['trim']); unset($code['validate']); unset($code['quoted']); unset($code['require_parents']); unset($code['require_children']); unset($code['disallow_children']); unset($code['parsed_tags_allowed']); } // If we are not doing every tag only do ones we are interested in. if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) $bbc_codes[substr($code['tag'], 0, 1)][] = $code;


in subs.php

emanuele

#6
It works fine in a fresh install, probably you have some other mod installed that changes this part of the file.

I've uploaded a new version that doesn't require this edit. ;)


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Jeet Chowdhury


emanuele

Open the file Subs-ShowBBCodeToGuests.php (in Sources), then search for:
$code['content'] = '<div style="display:block">' . $txt['mod_not_allowed_see'] . ' ' . $txt['login_or_register'] . '</div>';[/quote]
Here you can define the style of the "warning".

For example to show it like a quote you can change it to:
[code] $code['content'] = '<blockquote class="bbc_standard_quote">' . $txt['mod_not_allowed_see'] . ' ' . $txt['login_or_register'] . '</blockquote>';[/quote]

That could be a feature for the next version! ;)


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Jeet Chowdhury

thanks... :) can i remove quotes " sign from left side?

emanuele

Oh yes, I see.

Maybe try this instead:
$code['content'] = '<code class="bbc_code">' . $txt['mod_not_allowed_see'] . ' ' . $txt['login_or_register'] . '</code>';[/quote]


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Inti31

#11
it works fine - but there are 2 messages in the error log:

http://aida32-inventory.netboom.de/smf/index.php?topic=62.msg2238: Undefined index: login_or_register
Datei: /home/syscp/webs/<private>/smf/Sources/Subs-ShowBBCodeToGuests.php
line: 29


http://aida32-inventory.netboom.de/smf/index.php?topic=62.msg2238: Undefined index: mod_not_allowed_see
Datei: /home/syscp/webs/<private>/smf/Sources/Subs-ShowBBCodeToGuests.php
line: 29


I've put these strings in Modifications-german-utf8.php
$txt['mod_not_allowed_see'] = 'Sorry, es ist Dir nicht erlaubt den Inhalt zu sehen.';
$txt['login_or_register'] = 'Registriere Dich oder melde Dich an.';


What's wrong - line 29 refers to 'mod_not_allowed_see' and 'login_or_register'

Any idea?

cheers Inti31
my forum
my testforum


my mods - which I only made them work for 2.0 Gold:
Topics Filter v3.2 SMF 2.0 Gold
MemberNumber

emanuele

Both are rather strange errors for SMF 2.0...
But login_or_register it's *very* strange since this is an SMF text string and it isn't introduced by the mod...

I think you have some other problems with languages. Please check if you get the same error with English too.

And just to be sure it's only a typo: it should be Modifications.german-utf8.php ;)


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Inti31

#13
Quote from: emanuele on August 29, 2011, 09:32:08 AM
Both are rather strange errors for SMF 2.0...
But login_or_register it's *very* strange since this is an SMF text string and it isn't introduced by the mod...
it isn't?
Line 29 of Subs-ShowBBCodeToGuests.php shows:

$code['content'] = '<div style="display:block">' . $txt['mod_not_allowed_see'] . ' ' . $txt['login_or_register'] . '</div>';

and because I didn't find both strings I put them into Modifications.german-utf8.php...

Addition:
okay:
$txt['login_or_register'] is located in index.german-utf8.php.

I removed now that string from Modifications.german.utf8.php; am going to see if that was the mistake...

thx Inti31
my forum
my testforum


my mods - which I only made them work for 2.0 Gold:
Topics Filter v3.2 SMF 2.0 Gold
MemberNumber

emanuele

Quote from: Inti31 on August 29, 2011, 10:51:38 AM
it isn't?
As you already noticed login_or_register is not introduced by the mod (probably bad wording from my side, maybe "it is borrowed from SMF language strings" was a better way to say it), it's only used by the mod. ;)

That's way I said it's very strange you get an undefined index error with a "native" SMF string.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

RAULVK

¿Se podría modificar el código para que en vez en ocultar todo el BBC, solamente se oculte el contenido el bbc?




Could you modify the code so that instead to hide all the BBC, only the bbc hide content?


Sample:

emanuele

In Subs-ShowBBCodeToGuests.php, you can change the line:
$code['content'] = '<div class="sbtog_hideblock" style="display:block">' . $txt['mod_not_allowed_see'] . ' ' . $txt['login_or_register'] . '</div>';
adding all the formatting you want. ;)


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

RAULVK

#17
Thanks, but I do not think I explained well. What I want is to not hide all the bbc, only the content, so that each retains your style.






Not hide "before" and "after"

array(
'tag' => 'black',
'before' => '<span style="color: black;" class="bbc_color">',
'after' => '</span>',
),



emanuele

I understood what you wanted, but since you presented a very specific example (and we all know what it is for) I didn't consider worth the work needed. :P

Now Looking from another perspective I can see the advantage.
Updated the mod, maybe there are still few glitches with few tags, it needs a bit of testing.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

RAULVK

Ok, thanks for your attention.

Preserving the style, visitors will know what he is hiding y have a reason to register.


Advertisement: