vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Pass a vBulletin variable to Javascript? (https://vborg.vbsupport.ru/showthread.php?t=277317)

Honourable 01-20-2012 08:14 PM

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 :D

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

kh99 01-20-2012 08:51 PM

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.

Honourable 01-20-2012 09:03 PM

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

kh99 01-20-2012 09:34 PM

Hmm...OK, try this instead:

Code:

<script type="text/javascript">
<!--
var slideshow_width = parseInt("$vboptions[slideshow_width]", 10);
// -->
</script>


Honourable 01-20-2012 09:49 PM

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?

kh99 01-20-2012 09:59 PM

I don't know. Are you putting slideshow_width in place of the 610 in your js file? It seems like that should work.

Honourable 01-20-2012 10:02 PM

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?

kh99 01-20-2012 10:07 PM

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. :)

Honourable 01-20-2012 10:11 PM

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

Honourable 01-20-2012 10:15 PM

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


All times are GMT. The time now is 05:17 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.01069 seconds
  • Memory Usage 1,740KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete