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

Reply
 
Thread Tools Display Modes
  #1  
Old 04-29-2008, 08:47 PM
kronnos kronnos is offline
 
Join Date: Apr 2006
Posts: 241
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 04-30-2008, 01:21 AM
GameWizard's Avatar
GameWizard GameWizard is offline
 
Join Date: Apr 2004
Location: Vancouver, BC
Posts: 319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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>
$randombanner refers to the code where the banner is randomized to your liking.
Reply With Quote
  #3  
Old 04-30-2008, 08:28 AM
kronnos kronnos is offline
 
Join Date: Apr 2006
Posts: 241
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Cool, thanks!

Anyone else have some ideas?
Reply With Quote
  #4  
Old 04-30-2008, 11:38 AM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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>
Reply With Quote
  #5  
Old 04-30-2008, 11:49 AM
kronnos kronnos is offline
 
Join Date: Apr 2006
Posts: 241
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #6  
Old 04-30-2008, 12:16 PM
GameWizard's Avatar
GameWizard GameWizard is offline
 
Join Date: Apr 2004
Location: Vancouver, BC
Posts: 319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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))">
2. I'm not sure how the rand function works.

3. Yes insert the code you'd like where the $randombanner1 is located.
Reply With Quote
  #7  
Old 04-30-2008, 12:38 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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%.
Reply With Quote
  #8  
Old 04-30-2008, 01:01 PM
kronnos kronnos is offline
 
Join Date: Apr 2006
Posts: 241
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Opserty View Post
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%.
Great, I think I understand it now.... If 0(false) is picked, it will skip $randombanner1 and go to <else /> $randombanner2. If 3(1,2, or3) is picked, it will stay at $randombanner1. Right?

Thank you very much. Great help!
Reply With Quote
  #9  
Old 05-01-2008, 05:54 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kronnos View Post
Great, I think I understand it now.... If 0(false) is picked, it will skip $randombanner1 and go to <else /> $randombanner2. If 3(1,2, or3) is picked, it will stay at $randombanner1. Right?

Thank you very much. Great help!
Yes
Reply With Quote
  #10  
Old 05-01-2008, 12:43 PM
kronnos kronnos is offline
 
Join Date: Apr 2006
Posts: 241
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
<if condition="in_array($bbuserinfo[userid], array(132))">
    
GOOGLE CODE1


</else>
<if 
condition="in_array($bbuserinfo[userid], array(213))">

GOOGLE CODE2

    
</else>
        <if 
condition="rand(0, 3)">
            
GOOGLE CODE1

        
<else />

GOOGLE CODE2


        
</if>
    </if>
</if> 
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 04:44 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06542 seconds
  • Memory Usage 2,265KB
  • 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
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete