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 01-20-2012, 08:14 PM
Honourable Honourable is offline
 
Join Date: Oct 2010
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Pass a vBulletin variable to Javascript?

Hi

I had a jquery slideshow which is working through js file called preview.js

I have in this js file width & height for the slideshow

and I would like to add a variable in the slideshow that if I from admincp edited the width to specific size then change and if not keep it as a specific size I want to remain

I found this thread but for vb4 any suggestion for vb3?
https://vborg.vbsupport.ru/showthread.php?t=264472

I'm really interesting in this therefore if any one by any chance would help me I will appreciate that

I have attached the jquery js file hope you could add a variable to it as in the thread for vb4 and you will find the width and height in fourth line so just make your edit please and then how to make the code in the global_start hook

waiting...

thank you
Reply With Quote
  #2  
Old 01-20-2012, 08:51 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think you just need to create your admincp option, then put something like this in the headinclude template:

Code:
<script type="text/javascript">
<!--
var slideshow_width = $vboptions['slideshow_width'];
// -->
</script>

then use slideshow_width in your jx file.
Reply With Quote
Благодарность от:
Honourable
  #3  
Old 01-20-2012, 09:03 PM
Honourable Honourable is offline
 
Join Date: Oct 2010
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The problem it doesnt work

what because it's jquery file not straight away a code on the page

and moreover I did what you have told me but nothing happens?

--------------- Added [DATE]1327097665[/DATE] at [TIME]1327097665[/TIME] ---------------

moreover it gives me


Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/lywomen/public_html/test/includes/adminfunctions_template.php(3942) : eval()'d code on line 8

in 3.8.7
Reply With Quote
  #4  
Old 01-20-2012, 09:34 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm...OK, try this instead:

Code:
<script type="text/javascript">
<!--
var slideshow_width = parseInt("$vboptions[slideshow_width]", 10);
// -->
</script>
Reply With Quote
  #5  
Old 01-20-2012, 09:49 PM
Honourable Honourable is offline
 
Join Date: Oct 2010
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hey kh99

I really addore you ^^ but the problem the slides appear abnormall like I did the size is 610 for width I felt like the java count it as 100% not pixel?

am I correct?
Reply With Quote
  #6  
Old 01-20-2012, 09:59 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't know. Are you putting slideshow_width in place of the 610 in your js file? It seems like that should work.
Reply With Quote
  #7  
Old 01-20-2012, 10:02 PM
Honourable Honourable is offline
 
Join Date: Oct 2010
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

the problem is from the code

because when I changed the size directly from js file it works fine? but when I change it through the vbulletin it doesnt work probably and I THOUGHT BECAUSE IT GOES THROUGH THE CODE AND THERE IS SOMETHING WOULD BE CAUSE THE ISSUE IN THE CODE

WHAT YOU THINK ABOUT PERSEINT?
Reply With Quote
  #8  
Old 01-20-2012, 10:07 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, I created my own option called slideshow_width and set it to 610, then put the above code in my headinclude template. Then in the footer template I put this:

Code:
<script>
document.writeln('Width ' + slideshow_width);
</script>

and it displays

Code:
Width 610
at the bottom of my page. So it looks like the variable is being set to 610. I don't know why it wouldn't work in place of an integer constant in your .js file, but I'm not really a javascript expert. You have to figure out some way to debug it. Like maybe put this in you js file:

Code:
window.alert("slideshow_width is " + slideshow_width");

and see what it says.

Also, don't type in all caps, it looks like you're yelling.
Reply With Quote
  #9  
Old 01-20-2012, 10:11 PM
Honourable Honourable is offline
 
Join Date: Oct 2010
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

to be honest I dont know the function that going to print this code

PHP Code:
<script type="text/javascript">
<!--
var 
lywomen_slideshow_width parseInt("$vboptions[lywomen_slideshow_width]"10);
var 
lywomen_slideshow_height parseInt("$vboptions[lywomen_slideshow_height]"10);
// -->
window.alert("lywomen_slideshow_width is " lywomen_slideshow_width");
</script> 
to the headinclude template because I put it straight away in the main template of the hack

if you can give me the function I would appreciate that

^^

I think something like copy this code to headinclude cache

thank you
Reply With Quote
  #10  
Old 01-20-2012, 10:15 PM
Honourable Honourable is offline
 
Join Date: Oct 2010
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

when I check the code through source

it appears like this

<script type="text/javascript">
<!--
var lywomen_slideshow_width = parseInt("610", 10);
var lywomen_slideshow_height = parseInt("439", 10);
// -->
</script>

which is works 100%

but the problem I think it's with the controduct in the js file which is this one I uploaded

for you again
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 05:58 AM.


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.04280 seconds
  • Memory Usage 2,266KB
  • 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
  • (5)bbcode_code
  • (1)bbcode_php
  • (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
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete