Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: getandshare on May 03, 2009, 01:28:05 AM

Title: How to Hide stuffs inside Code Tags
Post by: getandshare 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.
Title: Re: How to Hide stuffs inside Code Tags
Post by: niko 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)

'tag' => 'code',


Next line will have something like

'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:

'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)
Title: Re: How to Hide stuffs inside Code Tags
Post by: getandshare 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
Title: Re: How to Hide stuffs inside Code Tags
Post by: [SiNaN] on May 11, 2009, 09:01:20 AM
Edits Niko mentioned should go in Subs.php file.
Title: Re: How to Hide stuffs inside Code Tags
Post by: getandshare 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. :)
Title: Re: How to Hide stuffs inside Code Tags
Post by: getandshare 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.
Title: Re: How to Hide stuffs inside Code Tags
Post by: getandshare 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.
Title: Re: How to Hide stuffs inside Code Tags
Post by: IchBin™ on July 01, 2009, 04:53:04 PM
'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.
Title: Re: How to Hide stuffs inside Code Tags
Post by: getandshare 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 ;)
Title: Re: How to Hide stuffs inside Code Tags
Post by: [SiNaN] 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

in_array(4, $user_info['groups'])

you could use:

$user_info['posts'] < 5
Title: Re: How to Hide stuffs inside Code Tags
Post by: getandshare 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
Title: Re: How to Hide stuffs inside Code Tags
Post by: [SiNaN] on July 20, 2009, 11:49:12 AM
'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>'),
Title: Re: How to Hide stuffs inside Code Tags
Post by: thepitster 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
'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
'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
$user_info['posts'] < 5 ? '<b>You need a 5 post minimum to see code and url tags! </b>' :
like so:
'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>' : ''),
'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

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;
'),
),

'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.