Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-20-2011, 04:15 AM
genxstan genxstan is offline
 
Join Date: Nov 2009
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Hide code tags from certain usergroups ?

Hi guys ,
Can someone direct me ,how to hide something written in code tags
Code:
Hide this
for unregistered users ?
I like to hide user-group 1,3 . Since i dont know how to do it ,i just removed these Forum Viewing Permissions for unregistered user-group.
Quote:
Can View Others' Threads
Can View Thread Content
Which is really hurting Google traffic .

My VB version 4.1.5

I have been reading vBulletin Template Conditionals and its not getting me anywhere.
Reply With Quote
  #2  
Old 11-20-2011, 05:07 AM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$string = preg_replace(/\[code\].*\[\/code\]/i, "", $string);

I think that'll knock them out of $string. Are you good with plugins?

EDIT: Wait a minute, let me work on that some more.

EDIT2:

Here we go (I think)

$string = preg_replace(/\[code\][\s\S]*?\[\/code\]/i, "", $string);

--------------- Added [DATE]1321771433[/DATE] at [TIME]1321771433[/TIME] ---------------

All wrong about that. What I posted would match bb code. You will need to match html for a code box

PHP Code:
$regexp '/<div class="smallfont" style="margin-bottom:2px">Code:<\/div>[\s\S]*?<\/pre>/i';

$string preg_replace($regexp""$string); 
Reply With Quote
  #3  
Old 11-20-2011, 06:48 AM
genxstan genxstan is offline
 
Join Date: Nov 2009
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What are those things ? I have no idea where to use those ,other than adding some verification codes in header code of themes . I was used to marco hide plugin which isnt working anymore for last few months after VB 4.0.3 or something.
Reply With Quote
  #4  
Old 11-20-2011, 07:16 AM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Those things with all the slashes? Those are regular expressions. They describe patterns for matching strings of characters and you can use the preg_replace function to replace one string of characters with another (or with a blank).

You'll never get anywhere with template conditionals, this has to be done at the php level. I'd work on it but I can't get a reliable connection to my server right now so I can't view any files.

Or do you mean plugins? Those are chunks of code inserted into files (well, sort of). Anyway you'll need one.
Reply With Quote
Благодарность от:
Liff
  #5  
Old 11-20-2011, 07:45 AM
Liff Liff is offline
 
Join Date: Aug 2011
Posts: 73
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I would be very interested in this too, nerbert.

Thanks for taking the time to look at it.
Reply With Quote
  #6  
Old 11-20-2011, 08:01 AM
genxstan genxstan is offline
 
Join Date: Nov 2009
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In Style manager - Edit Templates - BB Code Layout Templates - bbcode_code

I changed default code

Code:
<div class="bbcode_container">
	<div class="bbcode_description">{vb:rawphrase code}:</div>
	<pre class="bbcode_code"<vb:if condition="$vboptions['codemaxlines']">style="height:<vb:if condition="$blockheight<$vboptions['codemaxlines']">{vb:math {vb:raw blockheight}*{vb:stylevar mid_fontSize}+{vb:stylevar mid_fontSize}*2}<vb:else />{vb:math {vb:raw blockheight}*{vb:stylevar mid_fontSize}+{vb:stylevar mid_fontSize}}</vb:if>;"</vb:if>>{vb:raw code}</pre>
</div>
to

Code:
<vb:if condition="is_member_of($bbuserinfo, 2,7,5,6,9)">

<div class="bbcode_container">
	<div class="bbcode_description">{vb:rawphrase code}:</div>
	<pre class="bbcode_code"<vb:if condition="$vboptions['codemaxlines']">style="height:<vb:if condition="$blockheight<$vboptions['codemaxlines']">{vb:math {vb:raw blockheight}*{vb:stylevar mid_fontSize}+{vb:stylevar mid_fontSize}*2}<vb:else />{vb:math {vb:raw blockheight}*{vb:stylevar mid_fontSize}+{vb:stylevar mid_fontSize}}</vb:if>;"</vb:if>>{vb:raw code}</pre>
</div>

<vb:else />
<a href="http://site.com/register.php" target="_blank"> <img src="http://site.com/images/no_links_here.png"> </a>
</vb:if>
Add usergroup Numbers to this
$bbuserinfo, 2,7,5,6,9 which are the ones whom i want to show the code contents like registred users,moderators etc. For others the code wont show as i have added <vb:else /> to that.


I'm testing it and i'll be looking for users complaints if they cant view threads with code.
Reply With Quote
  #7  
Old 11-20-2011, 08:52 AM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmmm ... that might work. I'm getting close but am having a glitch.

What about PHP and HTML tags?
Reply With Quote
  #8  
Old 11-20-2011, 09:41 AM
genxstan genxstan is offline
 
Join Date: Nov 2009
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No idea about other tags ,i've taken note for the bbcode conditionals from this site,so i made this even though i never did that. Hope it works without bugs.
Will report back if code is problematic.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:20 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.19861 seconds
  • Memory Usage 2,239KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (1)post_thanks_box_bit
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete