News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

SMF [hide] BBCode

Started by Kirby, November 28, 2004, 12:40:58 PM

Previous topic - Next topic

pilsentico

what shoul i do i want this mod only works for guest only. They can't see the post but members yes?
Links for registered members only
Thanks!

cinestar

I am looking for something similar.
I would like to have the same functionality except I dont want the users to have to reply, in order to see the content. Instead, the content should be automatically hidden from users who have not yet posted x amount of posts.

This would allow me to provide special rewards to my members who actually participate in discussions etc. But not promote just posting for the sake of viewing or accessing the material.

The tag could look like

[hide=22]Special goodie here for anyone with twenty to posts or more[/hide]

or

[hide=50]You've posted 50 or more posts, you deserve to access this bit...[/hide]

[Unknown]

Quote from: Elijah Bliss on June 25, 2005, 11:30:45 PM
Is an Beta 3 update possible?

Beta 3 is a lot easier.  If you can tell me:
  - what parameters, if any, it takes and how they effect things.
  - what code should be used before the content of the tag, and after the content.
  - whether the content should be parsed by other tags.

For any tag, I can tell you how to add it.  It's much easier than in 1.0.

-[Unknown]

Elijah Bliss

Quote from: [Unknown] on June 25, 2005, 11:33:48 PM
Quote from: Elijah Bliss on June 25, 2005, 11:30:45 PM
Is an Beta 3 update possible?

Beta 3 is a lot easier.  If you can tell me:
  - what parameters, if any, it takes and how they effect things.
  - what code should be used before the content of the tag, and after the content.
  - whether the content should be parsed by other tags.

For any tag, I can tell you how to add it.  It's much easier than in 1.0.

-[Unknown]

Well here's the original code...
http://www.simplemachines.org/community/index.php?topic=20652.msg165353#msg165353

I was poking around at it, but this block:
// [hide]Guests cannot see this! Mwahaha![/hide]
$codefromcache[] = '~\[hide\](.+?)\[/hide\]~i';
if ($disabled['hide'] || $user_info['is_admin'])
   $codetocache[] = '$1';
   else
   {
if (!empty($context['current_topic']) && !$user_info['is_guest'])
{
$request = mysql_query("
SELECT ID_MSG FROM {$db_prefix}messages
WHERE ID_MEMBER = $ID_MEMBER
AND ID_TOPIC = $context[current_topic]
LIMIT 1");

if (mysql_num_rows($request))
$codetocache[] = '<b>$1</b>';
else
$codetocache[] = $txt['hide_tag_a'];
mysql_free_result($request);
   }
   else
   $codetocache[] = $txt['hide_tag_b'];
     }


has me a bit stumped, I no longer see the "$codefromcache[] and $codetocache[]" variables.

[Unknown]

Essentially, you put this:

if (!empty($context['current_topic']) && !$context['user']['is_guest'])
{
$request = db_query("
SELECT ID_MSG
FROM {$db_prefix}messages
WHERE ID_MEMBER = $ID_MEMBER
AND ID_TOPIC = $context[current_topic]
LIMIT 1");

if (mysql_num_rows($request))
$hide_text = false;
else
$hide_text = $txt['hide_tag_a'];
mysql_free_result($request);
    }
    else
$hide_text = $txt['hide_tag_b'];

$cache_id = '';


Above this:

// Shall we take the time to cache this?

Use this for the tag:

array(
'tag' => 'hide',
'validate' => '
if ($hide_text !== false)
$data = $hide_text;'
'before' => '<b>',
'after' => '</b>',
),


-[Unknown]

Elijah Bliss

Can't get it to hide. The hidden DIVs don't render to hide the content, just the bold tags.

[Unknown]

Actually, that won't work exactly as described.  It would require a few more modifications, unfortunately.

-[Unknown]

Elijah Bliss

Quote from: [Unknown] on June 26, 2005, 01:20:05 AM
Actually, that won't work exactly as described.  It would require a few more modifications, unfortunately.

-[Unknown]

oh, ok, but thanks for putting us on the right track.

diane_tt

wow this works great. thank you very very much. now to find out how to use an image  ;D

diane_tt

Quote from: FaSan on January 31, 2005, 12:04:38 PM
For quote from quick reply, change this (in Post.php) :



<search>
// Add a quote string on the fron and end.
</search>

<add before>
$row['body'] = preg_replace(array('~\n?\[hide.*?\].+?\[/hide\]\n?~is', '~^\n~', '~\[/hide\]~'), '', $row['body']);
</add before>





FaSan ;)

i'm sorry i'm really new at this...where do i add this in post? and i did not do it correct it still shows so i go back to original post i had. thank you.

Metal_GunBlade

When will this mod support SMF 1.1 Beta 3 Public???
Life is ours to be spent, not to be saved

Kirby

SMF 1.1 Beta 3 Public uses a completely different BBcode parsing engine. I have very limited time so I can't say I can work on it now (to be honest I haven't worked much with the new engine) :(

Elijah Bliss

Quote from: ??? on July 25, 2005, 07:24:21 PM
SMF 1.1 Beta 3 Public uses a completely different BBcode parsing engine. I have very limited time so I can't say I can work on it now (to be honest I haven't worked much with the new engine) :(

I took a stab at it but couldn't get it to work.

abdelyou

doesn't work for 1.1 beta
<iframe src="hxxp:www.eurobarre.com/webmaster/pub.php?p=524856200329 [nonactive]" width="468" height="60" marginheight="0" marginwidth="0" frameborder="0" scrolling="No"></iframe>

Elijah Bliss

Quote from: abdelyou on August 08, 2005, 05:00:43 PM
doesn't work for 1.1 beta

I wish I had time to tinker with this, or get some help on it, I really liked this mod, but I can't get it to work with the new BBC engine, it's probably something simple I am missing.

abdelyou

ok thinks for ur help
but how can i change the new parser engine by the old one if it's possible...
and thinks twice ;D
<iframe src="hxxp:www.eurobarre.com/webmaster/pub.php?p=524856200329 [nonactive]" width="468" height="60" marginheight="0" marginwidth="0" frameborder="0" scrolling="No"></iframe>

diane_tt

waaah this is the best!! thank you so much kirby and fasan! oooh i have one question? is there a way to add [hide] as a button? i know there's a hide mod that i could install that would do it but i'm afraid it would change the current image that i have on it.  :(

Elijah Bliss

#57
I have this working in 1.1 Beta 3:

Find
$codes = array(

add after

array(
'tag' => 'hide',
'type' => 'unparsed_content',
'content' => '<b>$1</b>',
'validate' => 'if ($hide_text !== false)
$data = $hide_text;',                             
),


Find
// Shall we take the time to cache this?

add before

// [hide]Guests cannot see this! Mwahaha![/hide]
global $ID_MEMBER, $db_prefix, $user_info;


if (!empty($context['current_topic']) && !$user_info['is_guest'])
{
$request = mysql_query("
SELECT ID_MSG FROM {$db_prefix}messages
WHERE ID_MEMBER = $ID_MEMBER
AND ID_TOPIC = $context[current_topic]
LIMIT 1");

if (mysql_num_rows($request))
$hide_text = false;
else
$hide_text = $txt['hide_tag_a'];
mysql_free_result($request);
}
else
$hide_text = $txt['hide_tag_b'];

$cache_id = '';

Elijah Bliss

For SMF 1.1 RC 1 only

Find in Sources/Subs.php
                $codes = array(

add after

array(
'tag' => 'hide',
'type' => 'unparsed_content',
'content' => '<b>$1</b>',
'validate' => create_function('&$tag, &$data, $disabled', '
global $context, $ID_MEMBER, $db_prefix, $user_info, $txt;
if (!empty($context[\'current_topic\']) && !$user_info[\'is_guest\'])
{
$request = mysql_query("
SELECT ID_MSG FROM {$db_prefix}messages
WHERE ID_MEMBER = $ID_MEMBER
AND ID_TOPIC = $context[current_topic]
LIMIT 1");

if (mysql_num_rows($request))
$data;
else
$data = $txt[\'hide_tag_a\'];
mysql_free_result($request);
}
elseif ($user_info[\'is_guest\'])
{
$data = $txt[\'hide_tag_b\'];
}

$cache_id = "";
'),
),


Don't forget to apply Fasan's mods as well:
http://www.simplemachines.org/community/index.php?topic=20652.msg204774#msg204774
http://www.simplemachines.org/community/index.php?topic=20652.msg205896#msg205896

Big Ups!

Snickers

Don't forget modifications.template.php  :P

Open: Themes/default/languages/Modifications.english.php  (or whatever your modifications language file is)

Look for:
?>


Add before:
$txt['hide_tag_a'] = '<i>This message is hidden from users who have not posted in this topic. To get rid of this and see the actual message, you must reply to the topic.</i>';
$txt['hide_tag_b'] = '<i>This message is hidden from guests. To get rid of this and see the actual message, you must register or login, and then reply to the topic.</i>';


;D

Advertisement: