The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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 |
#2
|
||||
|
||||
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)"> This will only show to Usergroup ID 2 </else> $randombanner </if> <if condition="is_member_of($bbuserinfo, 3)"> This will only show to Usergroup ID 3 </else> $randombanner </if> |
#3
|
|||
|
|||
Cool, thanks!
Anyone else have some ideas? |
#4
|
|||
|
|||
Code:
<if condition="is_member_of($bbuserinfo, 2)"> This will only show to Usergroup ID 2 </else> <if condition="is_member_of($bbuserinfo, 3)"> This will only show to Usergroup ID 3 </else> <if condition="rand(0, 3)"> $randombanner1 <else /> $randombanner2 </if> </if> </if> |
#5
|
|||
|
|||
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? |
#6
|
||||
|
||||
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. |
#7
|
|||
|
|||
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%. |
#8
|
|||
|
|||
Quote:
Thank you very much. Great help! |
#9
|
||||
|
||||
Yes
|
#10
|
|||
|
|||
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:
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|