1 (edited by Fil1958 2005-07-08 23:29)

Topic: BBcode [hide]

Hello everyone wink

I just made a little Mod to hide text in post with BBcode tags!

[hide]Hidden text[/hide]

It works with small text, smilies, but I got bugs with other BBcode... (code tag...)

You can test it here -> http://multy.freezee.org/viewtopic.php?pid=233#p233

Sorry I speak English like a Spanish cow :/
Multy Forums Free (Multi PunBB Project) (on stand by)
http://multy.forums.free.fr/forum_demo/

2

Re: BBcode [hide]

Very good !!! smile smile smile

3

Re: BBcode [hide]

and do you want to share the code with other

4 (edited by scottywz 2005-07-09 02:45)

Re: BBcode [hide]

Guests can see it if they quote you.

5

Re: BBcode [hide]

scottywz wrote:

Guests can see it if they quote you.

weird i cant see even if i quote him

6

Re: BBcode [hide]

what would this code be used for?
is it so you can hide certain parts of the post from different user groups?

7 (edited by Fil1958 2005-07-09 11:50)

Re: BBcode [hide]

BBcode [hide]

http://img143.imageshack.us/img143/2760/h6vz.gif

Only members can see hidden text !

the text is replaced with this...

http://img255.imageshack.us/img255/8489/hide8ej.gif


Edit 'include/parser.php'

Add the function

//
//Function hide text
//
function do_hide($text)
{
    global $pun_user;

    if ($pun_user['is_guest'])
        $text = preg_replace('#\[hide\](.*?)\[\/hide\]#si','<span><center><img src="./img/hide.gif"/></center></span>', $text);
    else
        $text = preg_replace('#\[hide\](.*?)\[\/hide\]#si','<span>$1</span>', $text);

        return $text;
}

Search

//
// Parse message text
//
function parse_message($text, $hide_smilies)
{
    global $pun_config, $lang_common, $pun_user;

    if ($pun_config['o_censoring'] == '1')
        $text = censor_words($text);

    // Convert applicable characters to HTML entities
    $text = pun_htmlspecialchars($text);

After Add

        $text = do_hide($text);

It's not perfect sad

Sorry I speak English like a Spanish cow :/
Multy Forums Free (Multi PunBB Project) (on stand by)
http://multy.forums.free.fr/forum_demo/

8 (edited by MathsIsFun 2005-08-03 03:41)

Re: BBcode [hide]

I have a variation on this that replaces the text with a button that pops up the "hidden" text when clicked. example on the Math Is Fun forum

This is so that people can solve math puzzles without giving the answer away to other puzzlers, yet their solution is still easy to find.

In parser.php I added:

function handle_hide_tag($text, $button = 'Show Hidden Text')
{
    global $pun_user;

        $s = '<span><form name="hide" method="post" action="message.php" style="display: inline;"><input type="hidden" name="msg" value="'.$text.'" style="border: 0; padding: 0;"><input type="submit" name="Submit" value="'.$button.'"></form></span>';

        return $s;
}

And also in parser.php I made the hide tag call up the handle_hide_tag function (like the url tag calls handle_url_tag), and ended up with this result in function do_bbcode():

    $pattern = array('#\[b\](.*?)\[/b\]#s',
                     '#\[i\](.*?)\[/i\]#s',
                     '#\[u\](.*?)\[/u\]#s',
                     '#\[url\](.*?)\[/url\]#e',
                     '#\[url=(.*?)\](.*?)\[/url\]#e',
                     '#\[email\](.*?)\[/email\]#',
                     '#\[email=(.*?)\](.*?)\[/email\]#',
                     '#\[hide\](.*?)\[/hide\]#e',     
                     '#\[hide=(.*?)\](.*?)\[/hide\]#e',
                     '#\[color=([a-zA-Z]*|\#?[0-9a-fA-F]{6})](.*?)\[/color\]#s');

    $replace = array('<strong>$1</strong>',
                     '<em>$1</em>',
                     '<span class="bbu">$1</span>',
                     'handle_url_tag(\'$1\')',
                     'handle_url_tag(\'$1\', \'$2\')',
                     '<a href="mailto:$1">$1</a>',
                     '<a href="mailto:$1">$2</a>',
                     'handle_hide_tag(\'$1\')',
                     'handle_hide_tag(\'$2\', \'$1\')',
                     '<span style="color: $1">$2</span>');

I then created a simple page "message.php" that simply displays the text neatly.
I know this is not a very good description of the changes, but hopefully there are enough clues here for anyone else to create this functionality

Re: BBcode [hide]

i want guest not see link download in my forum, please help me.

I'm from Viet Nam. i speak english vey bad! Sorry.

10 (edited by trongha 2006-06-13 01:36)

Re: BBcode [hide]

you can see in topic =>http://puntal.foxmask.info/forums/viewtopic.php?id=351

you have mod Download module, please send me.

I'm from Viet Nam. i speak english vey bad! Sorry.

Re: BBcode [hide]

is there a way to use this to force users to post to see something...?