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 08-08-2006, 11:47 PM
bhxtyrant bhxtyrant is offline
 
Join Date: Jun 2005
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Random image backround?

Hey guys,
I have a bit of a dilema here.I am currently searching for a random image script that makes the image change each time the page is refreshed/reloaded.I found a few that work fine but thats were the problem comes in.I am attempting to use this to make two images on my forum banner change at the same time so they match each other on each refresh but i can not find a script thaat does this.Due to my limited knowledge of PHP and javascript i can not make my own so i was hoping someone may be able to help me.

Im not sure exactly what info is needed so please let me know if you need anything and i will provide it.Thanks.
Reply With Quote
  #2  
Old 08-09-2006, 03:10 AM
lightwave lightwave is offline
 
Join Date: Sep 2004
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello, I have a random image in my website but it can work for background

here is the code:

PHP Code:
$random_bg=rand(1,23);
ECHO 
"<BODY STYLE=\"BACKGROUND-IMAGE:URL(http://yourwebsite.com/background_{$random_bg}.jpg);\">"
Basically, you name all your backgrounds

background_1.jpg
background_2.jpg


change the 23 in rand(1,23); to wahtever max images you have. if you have 10, then chagne it to rand(1,10);

then u just change the URL.
Reply With Quote
  #3  
Old 08-09-2006, 10:11 AM
bhxtyrant bhxtyrant is offline
 
Join Date: Jun 2005
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks lightwave,i will give it a try,do you know if this will work for two images?


This image shows the part of my page with the images i want to change,so maybe that will help answer this question a bit better.The only problem is i dont need a random backround script.I more so want the images to change in a certain order each time the page is refreshed.for example first refresh would make the top image number 1 and bottom image number 1 show,then it would go to top image number 2,bottom image number 2,and so on.
Reply With Quote
  #4  
Old 08-09-2006, 07:53 PM
pyro.699 pyro.699 is offline
 
Join Date: Sep 2005
Location: Fredericton, New Brunswic
Posts: 261
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What i would do in my case, is put all of the image files in an array
PHP Code:
$arr = array('image1.jpg''image2.jpg'
Then i would call it by going
PHP Code:
echo '<img src="./'.array_rand($arr).'"/>'
Reply With Quote
  #5  
Old 08-09-2006, 08:05 PM
bhxtyrant bhxtyrant is offline
 
Join Date: Jun 2005
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

would this work for backround images though?Sorry for the noob Q's i dont know very much PHP.
Reply With Quote
  #6  
Old 08-10-2006, 01:09 AM
pyro.699 pyro.699 is offline
 
Join Date: Sep 2005
Location: Fredericton, New Brunswic
Posts: 261
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yup, any images
Reply With Quote
  #7  
Old 08-15-2006, 05:06 PM
bhxtyrant bhxtyrant is offline
 
Join Date: Jun 2005
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hey guys sorry for the long overdue bump of this topic.I remebered something after reading up a bit that i needed to check on reguarding the above php array idea.I recall reading somewhere on this forum that php scripts will not work inside of the vbulliten templates so doesnt this mean that the array would not work as i want to use it in my vB header tamplate?
Reply With Quote
  #8  
Old 08-15-2006, 06:16 PM
pyro.699 pyro.699 is offline
 
Join Date: Sep 2005
Location: Fredericton, New Brunswic
Posts: 261
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you have to call the template dont you?

PHP Code:
$image array_rand($arr); 
^in your php file

and in your template call $image

HTML Code:
<body background-image="$image">
^ in your template

I think my html is wrong, but you get the idea
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 11:30 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.14704 seconds
  • Memory Usage 2,235KB
  • 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
  • (1)bbcode_html
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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_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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete