The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
How to input vbphrase in js
We can use vbphrase in js file like?
$vbphrase or {vb: rawphrase} I've tried two ways but not working |
#2
|
|||
|
|||
Since the js runs on the client browser, it won't have access to the vb variables. But what the vb code does is it creates js variables to makes some values available. If you look in the headinclude template you'll see a section like this:
Code:
var SESSIONURL = "{vb:raw session.sessionurl_js}"; var SECURITYTOKEN = "{vb:raw bbuserinfo.securitytoken}"; var IMGDIR_MISC = "{vb:stylevar imgdir_misc}"; var IMGDIR_BUTTON = "{vb:stylevar imgdir_button}"; //etc... If you are including your js file in a vbulletin template (or in html that's output by a vbulletin "powered" script) you can do something similar. You might be able to use $template_hook['headinclude_javascript'] to include it in the headinclude template, depending on your situation. |
#3
|
|||
|
|||
Here is a snippet of the file. js, and I want to use alternative vbpharse Thank
Code:
if(x.readyState==4&&x.status==200) { el.innerHTML=''; el=document.getElementById(id); el.innerHTML=x.responseText; document.getElementById(id2).innerHTML = "thank"; if (eval_str) eval(eval_str); } } |
#4
|
|||
|
|||
Where is that js file being included? It must be in a template or in html somewhere, right?
|
#5
|
|||
|
|||
Yes, it is located in one *.js file and I hook it to $template_hook ['headinclude_javascript']
|
#6
|
|||
|
|||
OK, so I guess now you have something like:
Code:
$template_hook['headinclude_javascript'] .= '<script type="text/javascript" src="something.js" ></script>'; So add something to the beginning, like this: Code:
$template_hook['headinclude_javascript'] .= '<script type="text/javascript"> var thanks_phrase = \'' . addslashes_js($vbphrase['thanks']) . '\'; </script> <script type="text/javascript" src="something.js" ></script>'; then in your js file use thanks_phrase, like: Code:
el.innerHTML=x.responseText; document.getElementById(id2).innerHTML = thanks_phrase; |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|