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 07-01-2009, 03:37 PM
DetroitYES's Avatar
DetroitYES DetroitYES is offline
 
Join Date: Mar 2009
Posts: 43
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Need advice on adding a simple echo function to vBulletin

So I've been working on a skin that involves alot of rollover images, and I need to preload these images in the body tag. FYI, I'm using the Mickey Mouse macromedia rollover scripts becasue that is what was used on the site that im adapting the skin to...

I know I could manually insert the onLoad Javascript function into the body tag of every page that I have the rollovers on, but this is obviously cumbersome, and if i need to add new images to the preload array, I would probably have to go back and do it by hand. So with my limited php knowledge, I came up with this script:

Code:
echo"
onLoad=\"MM_preloadImages(\'images/cmb_final/header_nav/MB-header-over_02.gif\',\'images/cmb_final/header_nav/MB-header-over_03.gif\',\'images/cmb_final/header_nav/MB-header-over_04.gif\',\'images/cmb_final/header_nav/MB-header-over_05.gif\',\'images/cmb_final/header_nav/MB-header-over_06.gif\',\'images/cmb_final/header_nav/MB-header-over_07.gif\',\'images/cmb_final/header_nav/MB-header-over_09.gif\',\'images/cmb_final/header_nav/MB-header-over_10.gif\',\'images/cmb_final/header_nav/MB-header-over_11.gif\',\'images/cmb_final/header_nav/01-CTIover.gif\',\'images/cmb_final/header_nav/02-CSSover.gif\',\'images/cmb_final/header_nav/03-CNGover.gif\',\'images/cmb_final/header_nav/04-CSAover.gif\',\'images/cmb_final/header_nav/04-CSAover.gif\',\'images/cmb_final/header_nav/05-HDover.gif\',\'images/cmb_final/left_side_nav/btn_weddings_over.gif\',\'images/cmb_final/left_side_nav/btn_Honeymoons_over.gif\',\'images/cmb_final/left_side_nav/n_btn_getQuote_over.gif\',\'images/cmb_final/left_side_nav/btn_aboutUs_over.gif\',\'images/cmb_final/left_side_nav/btn_photoGallery_over.gif\',\'images/cmb_final/left_side_nav/btn_couplesLounge_over.gif\',\'images/cmb_final/left_side_nav/btn_messageBoard_over.gif\',\'images/cmb_final/left_side_nav/btn_loyaltyProgram_over.gif\',\'images/cmb_final/left_side_nav/btn_preferredAgents_over.gif\',\'images/cmb_final/left_side_nav/btn_brochures_over.gif\',\'images/cmb_final/left_side_nav/btn_contactUs_over.gif\',\'images/cmb_final/left_side_nav/btn_faq_over.gif\',\'images/cmb_final/left_side_nav/btn_home_over.gif\',\'images/cmb_final/left_side_nav/btn_GroupBenefits.gif\',\'images/cmb_final/left_side_nav/btn_GroupBenefits_over.gif\')\""

Now if I assign a variable name to that and add that to this plugin which I'm already running, will that allow me to call the echo function on the page with just the variable name in the same fashion that I call in the templates?:

Code:
eval('$nbHeader = "' . fetch_template('nbHeader') . '";');
eval('$nbLeftSidebar = "' . fetch_template('nbLeftSidebar') . '";');
eval('$nbRightSidebar = "' . fetch_template('nbRightSidebar') . '";');
eval('$nbFooter = "' . fetch_template('nbFooter') . '";');
I'm presuming something like:

Code:
eval('$nbImgPreload = "echo' blah blah blah '";');
Would this work (and is my syntax clean?).
If not, can you point me in the right direction?
Also, if it will work, is there a more efficient way?

Thanks.

-----------------------------------------------------EDIT-----------------------------------------------------
after some embarrassingly long, hard thought I came up with the idea of creating a template with the image preloader code, and called that into the body tag. Now this works for the page I'm testing the template on ( forumdisplay ), but there are some foreseeable problems.

First off, when I have the setting "Add Template Name in HTML comments" turned on in the Forums General settings, this code does not render as html, because the comments end up in the <body> tag which causes all of the code in the template to be printed at the top of the page. This isn't a huge deal, as I can turn the setting off, but when I'm building a skin I like to see the name of which templates aren't cooperating. I'm toying with the idea of including the whole body tag in the template, but I've had trouble doing a site-wide search and replace of the body tag before in vBulletin...

Second and more importantly, I know a few pages already make use of the onLoad event in the body tag for purposes other than image preloads, how should I handle this?
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 06:52 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03111 seconds
  • Memory Usage 2,209KB
  • Queries Executed 11 (?)
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
  • (3)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)showthread_list
  • (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_threadedmode.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_threaded
  • showthread_threaded_construct_link
  • 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