Advertisement:

Author Topic: SMF [hide] BBCode  (Read 213950 times)

Offline pilsentico

  • Semi-Newbie
  • *
  • Posts: 13
Re: SMF [hide] BBCode
« Reply #40 on: June 02, 2005, 01:07:14 PM »
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!

Offline cinestar

  • Semi-Newbie
  • *
  • Posts: 12
Re: SMF [hide] BBCode
« Reply #41 on: June 25, 2005, 12:50:30 PM »
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]

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: SMF [hide] BBCode
« Reply #42 on: June 25, 2005, 11:33:48 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]

Offline Elijah Bliss

  • Sophist Member
  • *****
  • Posts: 1,340
Re: SMF [hide] BBCode
« Reply #43 on: June 25, 2005, 11:40:48 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:
Code: [Select]
// [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.

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: SMF [hide] BBCode
« Reply #44 on: June 26, 2005, 12:25:07 AM »
Essentially, you put this:

Code: [Select]
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:

Code: [Select]
// Shall we take the time to cache this?
Use this for the tag:

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

-[Unknown]

Offline Elijah Bliss

  • Sophist Member
  • *****
  • Posts: 1,340
Re: SMF [hide] BBCode
« Reply #45 on: June 26, 2005, 01:02:30 AM »
Can't get it to hide. The hidden DIVs don't render to hide the content, just the bold tags.

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: SMF [hide] BBCode
« Reply #46 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]

Offline Elijah Bliss

  • Sophist Member
  • *****
  • Posts: 1,340
Re: SMF [hide] BBCode
« Reply #47 on: June 26, 2005, 01:54:07 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.

Offline diane_tt

  • Semi-Newbie
  • *
  • Posts: 43
Re: SMF [hide] BBCode
« Reply #48 on: July 08, 2005, 06:21:31 PM »
wow this works great. thank you very very much. now to find out how to use an image  ;D

Offline diane_tt

  • Semi-Newbie
  • *
  • Posts: 43
Re: SMF [hide] BBCode
« Reply #49 on: July 08, 2005, 06:35:42 PM »
For quote from quick reply, change this (in Post.php) :


Code: [Select]
<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.

Offline Metal_GunBlade

  • Jr. Member
  • **
  • Posts: 134
  • Gender: Male
  • Life is ours to be spent, not to be saved
Re: SMF [hide] BBCode
« Reply #50 on: July 22, 2005, 01:25:55 PM »
When will this mod support SMF 1.1 Beta 3 Public???
Life is ours to be spent, not to be saved

Offline Kirby

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 2,040
  • Gender: Male
Re: SMF [hide] BBCode
« Reply #51 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) :(

Offline Elijah Bliss

  • Sophist Member
  • *****
  • Posts: 1,340
Re: SMF [hide] BBCode
« Reply #52 on: July 25, 2005, 11:07:01 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.

Offline abdelyou

  • Newbie
  • *
  • Posts: 2
  • Gender: Male
Re: SMF [hide] BBCode
« Reply #53 on: August 08, 2005, 05:00:43 PM »
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>

Offline Elijah Bliss

  • Sophist Member
  • *****
  • Posts: 1,340
Re: SMF [hide] BBCode
« Reply #54 on: August 08, 2005, 08:35:49 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.

Offline abdelyou

  • Newbie
  • *
  • Posts: 2
  • Gender: Male
Re: SMF [hide] BBCode
« Reply #55 on: September 03, 2005, 07:06:40 AM »
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>

Offline diane_tt

  • Semi-Newbie
  • *
  • Posts: 43
Re: SMF [hide] BBCode
« Reply #56 on: September 05, 2005, 10:17:22 PM »
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.  :(

Offline Elijah Bliss

  • Sophist Member
  • *****
  • Posts: 1,340
Re: SMF [hide] BBCode
« Reply #57 on: September 25, 2005, 04:53:44 AM »
I have this working in 1.1 Beta 3:

Find
Code: [Select]
$codes = array(
add after
Code: [Select]
array(
'tag' => 'hide',
'type' => 'unparsed_content',
'content' => '<b>$1</b>',
'validate' => 'if ($hide_text !== false)
$data = $hide_text;',                             
),

Find
Code: [Select]
// Shall we take the time to cache this?
add before
Code: [Select]
// [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 = '';
« Last Edit: September 25, 2005, 05:51:51 AM by Elijah Bliss »

Offline Elijah Bliss

  • Sophist Member
  • *****
  • Posts: 1,340
Re: SMF [hide] BBCode
« Reply #58 on: September 25, 2005, 05:51:07 AM »
For SMF 1.1 RC 1 only

Find in Sources/Subs.php
Code: [Select]
                $codes = array(
add after
Code: [Select]
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!

Offline Snickers

  • Jr. Member
  • **
  • Posts: 127
Re: SMF [hide] BBCode
« Reply #59 on: September 26, 2005, 11:07:45 AM »
Don't forget modifications.template.php  :P

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

Look for:
Code: [Select]
?>

Add before:
Code: [Select]
$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