![]() |
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'))">
Is there a way to simply add some type of REGEX to the conditional, so 'GoogleBot' will match the longer user agent string? Thanks!! |
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:
<if condition="$show_for_humans"> |
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? |
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. |
Quote:
Oh! No need to apologize. Your code worked fine. Here is final version I used: PHP Code:
|
I'm glad it worked (I didn't even tested :p )
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, |
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.
|
All times are GMT. The time now is 08:07 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|