Advertisement:

Author Topic: How to Hide stuffs inside Code Tags  (Read 3669 times)

Offline getandshare

  • Semi-Newbie
  • *
  • Posts: 35
  • Gender: Male
  • Help Us Grow.. Use www.v99.in
    • Get & Share:- A place to Get & Share all your needs
How to Hide stuffs inside Code Tags
« on: May 03, 2009, 01:28:05 AM »
Hi,
I had my forum locked for guests since long time...
I now want to open it,
All i want is that people could browse my whole forum as guest but they don't see Things/Lines which are inside CODE bb tag...

Can anyone help with it please


Edit- please check 5th post, slight modification needed.
« Last Edit: June 24, 2009, 05:29:52 PM by getandshare »

Offline niko

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 2,003
  • Gender: Male
    • Madjoki
Re: How to Hide stuffs inside Code Tags
« Reply #1 on: May 03, 2009, 03:56:50 AM »
Simplest way is to edit BBC code parsing so it uses different code for guest

Search for (there are multiple instances)
Code: [Select]
'tag' => 'code',

Next line will have something like
Code: [Select]
'content' => '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code>$1</code>',

After "'content' => "
Add $user_info['is_guest'] ? 'Register to see codes!' 

Like this:
Code: [Select]
'content' => $user_info['is_guest'] ? 'Register to see codes!' : '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code>$1</code>',

Do same for rest of code tags. After this they still can see code when quoting but it can be fixed by removing code sections before quoted code is shown. (ie. in un_preprasecode)

Offline getandshare

  • Semi-Newbie
  • *
  • Posts: 35
  • Gender: Male
  • Help Us Grow.. Use www.v99.in
    • Get & Share:- A place to Get & Share all your needs
Re: How to Hide stuffs inside Code Tags
« Reply #2 on: May 04, 2009, 09:22:35 AM »
Hi Niko,
Am little weak at coding in php... though i can code...

Can you tell me which files to edit... or can i just attach the files... where modifications need to be done...
Am using smf 2.0 RC1
theme  airymidnight

There are lots of mod's installed in the forum so i dont wana have things messed up... also about that quoting thing... guests aren permitted to post... so that won't do any problem isn't it?

Guests can view whole forum(only view) and can't view things inside code tags, i want there to say please register to see link which my registration link...

Can you please do it for me... i really need that
if yes please let me know which files to attach

Offline [SiNaN]

  • SMF Super Hero
  • *******
  • Posts: 11,526
  • Young and Foolish
    • SimplePortal
Re: How to Hide stuffs inside Code Tags
« Reply #3 on: May 11, 2009, 09:01:20 AM »
Edits Niko mentioned should go in Subs.php file.
Former SMF Core Developer | My Mods | SimplePortal

Offline getandshare

  • Semi-Newbie
  • *
  • Posts: 35
  • Gender: Male
  • Help Us Grow.. Use www.v99.in
    • Get & Share:- A place to Get & Share all your needs
Re: How to Hide stuffs inside Code Tags
« Reply #4 on: June 24, 2009, 05:15:32 PM »
Thanks for the above solution they were working cool.
Now i want a new modification in that.
If a person is unregistered he shall see "Register to see download link" but if he is registered and have post count less than 5, it shall say "You need minimum of 5 post to download from this forum".
I hope to hear a solution from you guys soon please. :)

Offline getandshare

  • Semi-Newbie
  • *
  • Posts: 35
  • Gender: Male
  • Help Us Grow.. Use www.v99.in
    • Get & Share:- A place to Get & Share all your needs
Re: How to Hide stuffs inside Code Tags
« Reply #5 on: June 26, 2009, 05:36:58 AM »
Ok lets suppose i made a post group named  newbie at post count 5.
As you checked for guest as ['is_guest']   , tell me how to check for group newbie. I'll handle rest code.

Offline getandshare

  • Semi-Newbie
  • *
  • Posts: 35
  • Gender: Male
  • Help Us Grow.. Use www.v99.in
    • Get & Share:- A place to Get & Share all your needs
Re: How to Hide stuffs inside Code Tags
« Reply #6 on: July 01, 2009, 11:11:04 AM »
Brother can you make it simple in a code like, if(){true statement}else{false statement}

Tell me what to enter inside if statement to check for my condition, than i'll nest it with my previous guest one.

Offline IchBin™

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 11,116
  • Gender: Male
  • I don't speak German.
Re: How to Hide stuffs inside Code Tags
« Reply #7 on: July 01, 2009, 04:53:04 PM »
Code: [Select]
'content' => in_array(4, $user_info['groups']) ? 'Register to see codes!' : '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code>$1</code>',
Assuming your newbie group's ID is 4, this should work.
IchBin™        TinyPortal

Offline getandshare

  • Semi-Newbie
  • *
  • Posts: 35
  • Gender: Male
  • Help Us Grow.. Use www.v99.in
    • Get & Share:- A place to Get & Share all your needs
Re: How to Hide stuffs inside Code Tags
« Reply #8 on: July 03, 2009, 02:04:33 PM »
Thats a smart move bro. I'll replace 4 with my group id and test in few days. Actually i'll nest it with old one to impose seperate restrictions for below newbie group. If registration check is passed than it ll check for that group ;)

Offline [SiNaN]

  • SMF Super Hero
  • *******
  • Posts: 11,526
  • Young and Foolish
    • SimplePortal
Re: How to Hide stuffs inside Code Tags
« Reply #9 on: July 13, 2009, 12:21:35 PM »
You could also use the $user_info['posts'] variable to check post count of the member like instead of

Code: [Select]
in_array(4, $user_info['groups'])
you could use:

Code: [Select]
$user_info['posts'] < 5
Former SMF Core Developer | My Mods | SimplePortal

Offline getandshare

  • Semi-Newbie
  • *
  • Posts: 35
  • Gender: Male
  • Help Us Grow.. Use www.v99.in
    • Get & Share:- A place to Get & Share all your needs
Re: How to Hide stuffs inside Code Tags
« Reply #10 on: July 17, 2009, 04:33:58 PM »
Quote
'content' =>$user_info['is_guest'] ? 'Register to see codes!' :$user_info['posts'] < 5 ? 'You need minimum of 5 posts to see links' : '<div class="codeheader">' . $txt['code'] . ': ($2) <a href="#" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code>$1</code>',

Can you guys correct this code please??
i want it to work like
Quote
if($user_info['is_guest'])
{
Register to see codes!
}
else
{
if($user_info['posts'] < 5)
{
You need minimum of 5 posts to see links
}
}

That means if user is guest... he see message as "Register to see link"
else if user is not guest but have post less than 5... he see message as "You need minimum of 5 posts to see links"
rest user see the post normaly.

currently am getting output from the code as
You needs minimum of 5 posts to see links even if user is guest.
Somehow conditions are not looping inside each other..

I need it done urgently please

Offline [SiNaN]

  • SMF Super Hero
  • *******
  • Posts: 11,526
  • Young and Foolish
    • SimplePortal
Re: How to Hide stuffs inside Code Tags
« Reply #11 on: July 20, 2009, 11:49:12 AM »
Code: [Select]
'content' => $user_info['is_guest'] ? 'Register to see codes!' : ($user_info['posts'] < 5 ? 'You need minimum of 5 posts to see links!' : '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code>$1</code>'),
Former SMF Core Developer | My Mods | SimplePortal

Offline thepitster

  • Semi-Newbie
  • *
  • Posts: 28
  • Gender: Male
    • ALLRiPPED
Re: How to Hide stuffs inside Code Tags
« Reply #12 on: July 11, 2017, 05:05:46 PM »
I know this is an old thread and please forgive me for bring it up, but I am trying to find a way to do this with [url][/url]
working with SMF 2.0.14 in Subs.php if you find these lines
Code: [Select]
'content' => '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div>' . ($context['browser']['is_gecko'] || $context['browser']['is_opera'] ? '<pre style="margin: 0; padding: 0;">' : '') . '<code class="bbc_code">$1</code>' . ($context['browser']['is_gecko'] || $context['browser']['is_opera'] ? '</pre>' : ''),and
Code: [Select]
'content' => '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div>' . ($context['browser']['is_gecko'] || $context['browser']['is_opera'] ? '<pre style="margin: 0; padding: 0;">' : '') . '<code class="bbc_code">$1</code>' . ($context['browser']['is_gecko'] || $context['browser']['is_opera'] ? '</pre>' : ''),and add
Code: [Select]
$user_info['posts'] < 5 ? '<b>You need a 5 post minimum to see code and url tags! </b>' :like so:
Code: [Select]
'content' => $user_info['posts'] < 5 ? '<b>You need a 5 post minimum to see code and url tags! </b>' : '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div>' . ($context['browser']['is_gecko'] || $context['browser']['is_opera'] ? '<pre style="margin: 0; padding: 0;">' : '') . '<code class="bbc_code">$1</code>' . ($context['browser']['is_gecko'] || $context['browser']['is_opera'] ? '</pre>' : ''),
Code: [Select]
'content' => < 5 ? '<b>You need a 5 post minimum to see code and url tags! </b>' : '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div>' . ($context['browser']['is_gecko'] || $context['browser']['is_opera'] ? '<pre style="margin: 0; padding: 0;">' : '') . '<code class="bbc_code">$1</code>' . ($context['browser']['is_gecko'] || $context['browser']['is_opera'] ? '</pre>' : ''),it works well to hide code tags stuff from users with less then 5 posts, but how can one go about hiding urls from user with less then 5 posts, I have tried to play with url tags but I got no luck on this

Code: [Select]
array(
'tag' => 'url',
'type' => 'unparsed_content',
'content' => '<a href="$1" class="bbc_link" target="_blank">$1</a>',
'validate' => create_function('&$tag, &$data, $disabled', '
$data = strtr($data, array(\'<br />\' => \'\'));
if (strpos($data, \'http://\') !== 0 && strpos($data, \'https://\') !== 0)
$data = \'http://\' . $data;
'),
),
Code: [Select]
'tag' => 'url',
'type' => 'unparsed_equals',
'before' => '<a href="$1" class="bbc_link" target="_blank">',
'after' => '</a>',
'validate' => create_function('&$tag, &$data, $disabled', '
if (strpos($data, \'http://\') !== 0 && strpos($data, \'https://\') !== 0)
$data = \'http://\' . $data;
'),
'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_after' => ' ($1)',
),
array(
'tag' => 'white',
'before' => '<span style="color: white;" class="bbc_color">',
'after' => '</span>',
),
);

any help would be greatly appreciated, and again sorry for dragging up an old post but it was close to the topic I was looking for.