![]() |
Random Conditional Help
Hi,
I have this complicated conditional I want to use for adds but have no idea how to code it. Here is what I want the conditional to say in words: If user xx1 is viewing the page, then show "adcode 1" If user xx2 is viewing the page, then show "adcode 2" Else, show randomly, 75% chance "adcode 1" and 25% chance "adcode 2". Many thanks in advance! Edit/Delete Message |
Well I can't help you with the randomization code, that's something you can look for elsewhere, since the code is out there, you just need to find it.
As for your request, here is something that should get you on your way: Code:
<if condition="is_member_of($bbuserinfo, 2)"> |
Cool, thanks!
Anyone else have some ideas? |
Code:
<if condition="is_member_of($bbuserinfo, 2)"> |
Cool, so this is the full code that will do what i need?
Few question: 1-- It says it will show to certain usergroups. Can you make it say for certain users not entire groups? 2-- "rand(0, 4)", what does 0 and 4 mean? 0 chances of banner 1 and all chances of banner 2? 3-- Should I just insert instead of "$randombanner1" the adsense code? Or do i put the $ infront of the code? |
1. http://www.vbulletin.com/forum/showthread.php?t=200894 - Use the conditionals you'd like, you're looking for:
Code:
<if condition="in_array($bbuserinfo[userid], array(X,Y,Z))"> 3. Yes insert the code you'd like where the $randombanner1 is located. |
Edit whoops I made a mistake with the rand options should be: [minicode]rand(0, 3)[/minicode] instead of 4
2). rand generates a random number (in this case between 0 and 3 inclusive) 0 is evaluated as false in a condition whilst any other number would be true so you have 0 = false, 1, 2 & 3 = true. 1:3 ratio which is same as 25%:75%. |
Quote:
Thank you very much. Great help! |
Quote:
|
Please help! I pasted the following code into the Vb Ad management block and it gives an error. Now i cant delete the code because it doesn't show a save button to save new changes.
PHP Code:
|
Oh dear I must have been half asleep when I wrote this the first time, try this:
Code:
<if condition="in_array($bbuserinfo[userid], array(132))"> |
Still get the following Vbulletin error message:
: <if condition="rand(0, 3)"> rand rand(0, 3) in_array() is_array() is_numeric() isset() empty() defined() array() can_moderate() can_moderate_calendar() exec_switch_bg() is_browser() is_member_of() --------------- Added [DATE]1209653757[/DATE] at [TIME]1209653757[/TIME] --------------- I now pasted this code directly into the template and got this error message: vBulletin Message The following template conditional expression contains function calls: <if condition="rand(0, 3)"> Function Name Usage in Expression rand rand(0, 3) With a few exceptions, function calls are not permitted in template conditional expressions. Please go back and re-write this expression. The following functions are allowed in template conditional expressions: in_array() is_array() is_numeric() isset() empty() defined() array() can_moderate() can_moderate_calendar() exec_switch_bg() is_browser() is_member_of() |
AdminCP > Plugins & Products > Add New Plugin. Set the following:
Product: vBulletin Hook Location: template_safe_functions Plugin PHP Code: PHP Code:
|
Works great! Thank You!
|
All times are GMT. The time now is 05:02 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:
|