The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
REGEX in vB Template Conditional
Hello!
We have some code we want to omit from the template if the USER_AGENT is GoogleBot, Mediapartners-Google, etc. For example (not working code) Code:
<if condition="!in_array($_SERVER['HTTP_USER_AGENT'], array('GoogleBot','Mediapartners-Google'))"> <!-- this is the code --> </if>
Is there a way to simply add some type of REGEX to the conditional, so 'GoogleBot' will match the longer user agent string? Thanks!! |
#2
|
||||
|
||||
You will need to create a Plugin.
Product: vBulletin Name: Hide Content From Bots Hook: showthread_start Execution order: 5 PHP Code:
Then use the condition either this: Code:
<if condition="$show_for_humans"> code to be show only for humans </if> Code:
<if condition="$show_for_humans"> code to be show only for humans <else /> the replacement text for bots </if> |
#3
|
|||
|
|||
Thanks! I'll give it a "plug" and see how it works!
--------------- Added [DATE]1256975400[/DATE] at [TIME]1256975400[/TIME] --------------- I could not get this to work (for our purposes) in the hook location showthread_start, but I was able to get it to work in postbit_display_start. Perhaps this is because the content we are masking is in the content of the postbit template? |
#4
|
||||
|
||||
Yes. Sorry for not asking or better explaining this.
Leave as postbit_display_start if you're not going to use it elsewhere, or try another location, like global_start if you're going to use it widely in your boards. |
#5
|
|||
|
|||
Quote:
Oh! No need to apologize. Your code worked fine. Here is final version I used: PHP Code:
|
#6
|
||||
|
||||
I'm glad it worked (I didn't even tested )
If you (or anybody) want this as a product, with ACP options (a bot list management), send me a PM so we can discuss details and price. Regards, |
#7
|
|||
|
|||
FWIW, I cannot get this plugin to work in postbit if I move it to the hook global_start however it works fine if the hook is postbit_display_start.
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|