View Full Version : Adding javascript to head of custom vbulletin powered page
Chunky Monkey
10-22-2008, 11:06 AM
Hi,
I created a custom vbulletin page that needs some javascript in the head tag in order for it to work properly.
Can somebody please tell me how I can include the javascript in the <head> for this php script only?
Thank you!
Dismounted
10-22-2008, 11:50 AM
In your custom template, you can place code inside the head tags.
Chunky Monkey
10-22-2008, 05:42 PM
Can you please tell me which template I want to edit? I checked out header and header includes but neither looked right. Thanks!
--------------- Added 1224701029 at 1224701029 ---------------
Is it GENERIC_SHELL that I want? or maybe header include after all?
Lynne
10-22-2008, 05:48 PM
You said you created a custom page. So, what is the name of the template you created to use with that custom page?
Chunky Monkey
10-22-2008, 06:20 PM
Thanks for responding, Lynne. I got it to work by adding the javascript that needed to go in the <head></head> tags to the headerinclude template.
However, it's now being put in every page when it is only needed in one. Do you know the conditional I can use to make the javascript only appear when i'm at that certain page? I think it's something like
<if condition="is_script(MYSCRIPTNAME)">
blah...
</if>
Thank you
Lynne
10-22-2008, 07:34 PM
<if condition="THIS_SCRIPT == 'yourpage'>
blah...
</if>
You need to have defined THIS_SCRIPT at the top of your php script.
Chunky Monkey
10-22-2008, 07:51 PM
Thanks, Lynne. I defined THIS_SCRIPT as instructed by the "how to add vbulletin powered pages article".
It worked perfectly, thank you again!
Dismounted
10-23-2008, 09:34 AM
Even though it will only display your JS code on your page, the condition is executed on every page (nothing on its own, but every little bit counts). The best solution would be creating your own template, and putting the code inside that template, instead of the current solution.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.