Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: emanuele on February 11, 2011, 11:55:19 AM

Title: Show BBCode content to guests
Post by: emanuele on February 11, 2011, 11:55:19 AM
Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=2861)

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
Title: Re: Show BBCode content to guests
Post by: jaisi on March 22, 2011, 04:43:47 PM
i have install this mod but it's not working, where can i found that hide tag setting ??
Title: Re: Show BBCode content to guests
Post by: emanuele on March 23, 2011, 12:11:40 PM
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... :-[
Title: Re: Show BBCode content to guests
Post by: pizad_sura on March 25, 2011, 11:07:51 AM
not work any way : (
Title: Re: Show BBCode content to guests
Post by: emanuele on March 25, 2011, 11:15:49 AM
Guests can still see the content of bbcodes?
Or you don't see any option in the admin page?
Title: Re: Show BBCode content to guests
Post by: Jeet Chowdhury on June 13, 2011, 10:35:33 AM
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
Title: Re: Show BBCode content to guests
Post by: emanuele on June 13, 2011, 11:24:31 AM
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. ;)
Title: Re: Show BBCode content to guests
Post by: Jeet Chowdhury on June 13, 2011, 01:04:14 PM
Thanks.... :)

Can I Do this like??
Title: Re: Show BBCode content to guests
Post by: emanuele on June 13, 2011, 01:30:33 PM
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! ;)
Title: Re: Show BBCode content to guests
Post by: Jeet Chowdhury on June 13, 2011, 04:20:18 PM
thanks... :) can i remove quotes " sign from left side?
Title: Re: Show BBCode content to guests
Post by: emanuele on June 13, 2011, 06:01:42 PM
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]
Title: Re: Show BBCode content to guests
Post by: Inti31 on August 29, 2011, 05:30:07 AM
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
Title: Re: Show BBCode content to guests
Post by: 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...

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 ;)
Title: Re: Show BBCode content to guests
Post by: Inti31 on August 29, 2011, 10:51:38 AM
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
Title: Re: Show BBCode content to guests
Post by: emanuele on August 29, 2011, 11:37:47 AM
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.
Title: Re: Show BBCode content to guests
Post by: RAULVK on November 24, 2011, 04:36:19 PM
¿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:
(http://s2.subirimagenes.com/imagen/previo/thump_7173272sin-ttulo.png)
Title: Re: Show BBCode content to guests
Post by: emanuele on November 25, 2011, 12:12:39 PM
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. ;)
Title: Re: Show BBCode content to guests
Post by: RAULVK on November 25, 2011, 07:56:20 PM
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.

(http://img338.imageshack.us/img338/7563/sinttulo2tf.png)




Not hide "before" and "after"

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


Title: Re: Show BBCode content to guests
Post by: emanuele on November 26, 2011, 09:05:50 AM
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.
Title: Re: Show BBCode content to guests
Post by: RAULVK on November 26, 2011, 10:17:44 AM
Ok, thanks for your attention.

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

Title: Re: Show BBCode content to guests
Post by: emanuele on November 26, 2011, 12:20:59 PM
Depends on the visitor. :P

/me wonders why he did this mod in the first place... ???
Title: Re: Show BBCode content to guests
Post by: RAULVK on November 26, 2011, 09:41:48 PM
Ouuu!!!! Thanks for the 0.1.6 versión emanuele!
Title: Re: Show BBCode content to guests
Post by: Shrink on December 09, 2011, 09:45:24 AM
hello sir
At first it is only one mod which is compatible with SMF2.0.1 regarding BBC codes. In its newest release it allowed to stop/ hide any particular BBC code to guest.
Now i have little improvement. when we decide to hide BBC from guest we put our scrip/code for guest  member group. Then shall we add such setting that we can change this guest member group to other member (say Jr. Member)? In this way we can set particular BBC code stetting for each group.
I am asking for this help because i want to hide some VIP content from normal user. IT is allowed to view to only paid members.
what you say?
Title: Re: Show BBCode content to guests
Post by: emanuele on December 09, 2011, 05:30:46 PM
The way the mod works now it would be useless. A quote would be enough to reveal the hidden text.

If you want to have "VIP" content the best way would be to set up a board only for a certain membergroup. ;)
Title: Re: Show BBCode content to guests
Post by: than on April 13, 2012, 04:06:08 PM
Hi emanuele,

Really nice you mod, it´s basic in my community but I don´t understand why it´s generating a lot of errors in error log. I think every time a visitor view a post with a hidden htl (the bbc code i´m hiding) generates this error:

http://www.xxxxxxxxxx.es/index.php?dummy=1&amp;topic=1689.msg4654
8: Array to string conversion
Archivo: /xxx/xxxxxx/xxxxxxx/www/Sources/Subs.php(1611) : runtime-created function
Líne: 1

The installation was correct, the language strings are correct in modifications-utf8.... Only stop the error when I let the guests to see all bbc codes or when I uninstall the mod.

Please I need your help.
Best regards.
Than.
Title: Re: Show BBCode content to guests
Post by: emanuele on April 13, 2012, 06:24:17 PM
Hi than,

I wonder why I wrote it... :P

May I ask you to attach here your Subs.php?
Title: Re: Show BBCode content to guests
Post by: than on April 14, 2012, 05:34:30 AM
Ok, I attached it.

Thank´s  ;)
Title: Re: Show BBCode content to guests
Post by: emanuele on April 14, 2012, 06:29:40 AM
At line 1611 there is the url tag, and I can't find any "htl" tag, so which tag are you hiding?
Title: Re: Show BBCode content to guests
Post by: than on April 14, 2012, 06:31:34 AM
url, sorry i´m referring to url not html  ::)
Title: Re: Show BBCode content to guests
Post by: emanuele on April 14, 2012, 08:12:20 AM
Fixed (I hope).
Title: Re: Show BBCode content to guests
Post by: than on April 14, 2012, 08:13:40 AM
Wat I should to do?
Title: Re: Show BBCode content to guests
Post by: NanoSector on April 14, 2012, 08:16:11 AM
A new version of the mod is uploaded to the mod site, install that :)
Title: Re: Show BBCode content to guests
Post by: than on April 14, 2012, 08:22:04 AM
Impresed with your support. Installed the new version, and working perfect.


Really nice joob guys  :laugh:

Best regards.  ;)
Title: Re: Show BBCode content to guests
Post by: mladja037 on July 26, 2012, 04:04:04 PM
This mod not working for youtube bbcode? :/
Title: Re: Show BBCode content to guests
Post by: emanuele on July 27, 2012, 04:13:35 AM
Which one?
Title: Re: Show BBCode content to guests
Post by: mladja037 on July 27, 2012, 06:20:24 AM
http://custom.simplemachines.org/mods/index.php?mod=2861
Title: Re: Show BBCode content to guests
Post by: emanuele on July 27, 2012, 06:23:07 AM
I know that...I mean which youtube bbcode.
Title: Re: Show BBCode content to guests
Post by: mladja037 on July 27, 2012, 06:37:03 AM
http://custom.simplemachines.org/mods/index.php?mod=936
Title: Re: Show BBCode content to guests
Post by: emanuele on July 27, 2012, 09:28:47 AM
Okay, got it.
In Subs-ShowBBCodeToGuests.php:
Code (find) Select
if (isset($code['validate']) && !in_array($code['tag'], $no_beforeafter_tags))
$code['validate'] = create_function('&$tag, &$data, $disabled', '
$data = \'' . $warning_text . '\';
');

Code (replace with) Select
if (isset($code['validate']) && !in_array($code['tag'], $no_beforeafter_tags))
{
$code['validate'] = create_function('&$tag, &$data, $disabled', '
$data = \'' . $warning_text . '\';
');
if (!isset($code['content']))
$code['content'] = '$1';
}
Title: Re: Show BBCode content to guests
Post by: sangham.net on February 25, 2013, 12:18:41 PM
Dear emanuele,

maybe a silly question. I am not sure. Does the mod work on 2.0.4 as well? Thanks for your replay!
The question goes to others as well if they could help me out.

Thanks a lot!

(http://sangham.net/Smileys/sadhu_sangham.gif)

Title: Re: Show BBCode content to guests
Post by: emanuele on March 02, 2013, 09:01:17 AM
Yep, it works.
Title: Re: Show BBCode content to guests
Post by: sangham.net on March 02, 2013, 09:11:16 AM
Quote from: emanuele on March 02, 2013, 09:01:17 AM
Yep, it works.
Thanks a lot for your answer!

(http://sangham.net/Smileys/sadhu_sangham.gif)
Title: Re: Show BBCode content to guests
Post by: moal on April 07, 2014, 04:31:53 AM
Hello together,

I 've been using for 1year the cb | GeSHi -mod. Now I have also installed the "Show BBCode content to guests"-modification. http://custom.simplemachines.org/mods/index.php?mod=2861
I think it is a very useful modification , thank you for that.

It works for images with no problems. Instead picture the warning message appears .
For code, it only works if I use the normal code container by SMF. Then a code container appears , in which instead code the warning message is displayed.

Do I use the cb | GeSHi -mod the code container is apparently not recognized as such. And there where the code should be container only appears a <
I suspect that is because the SMF code container is opened with [code] and of cb | GeSHi -mod with [code = language ]

Is there any way to use both together ?
I would appreciate the help very much.

Many thanks and best regards
moal


Sorry, incidentally, I do not speak English and therefore use the Google translator.
Title: Re: Show BBCode content to guests
Post by: emanuele on April 09, 2014, 08:27:37 AM
For the way the GeSHi mod is coded, it's not possible to have something really nice without an "exception", but I don't like exceptions and unfortunately at the moment I'm a bit short of time, so I can't have a look at it.
The fastest way is to replace:
$code['validate'] = create_function('&$tag, &$data, $disabled', '
$data = \'' . $warning_text . '\';
');

with:

$code['validate'] = create_function('&$tag, &$data, $disabled', '
if (is_array($data))
$data[0] =\'' . $warning_text . '\';
else
$data = \'' . $warning_text . '\';
');

in Subs-ShowBBCodeToGuests.php.
It's not nice, but it works.
Title: Re: Show BBCode content to guests
Post by: moal on May 06, 2014, 08:02:50 AM
Danke, das hilft mir weiter...  :laugh:
Title: Re: Show BBCode content to guests
Post by: -Captain Ghost- on August 11, 2014, 08:02:31 AM
Hello,
First of all great mod no problem with it's functioning but is there anyway by which it can show an image instead of text that "sorry guest ..... Please Login or register"

thanks,  :)