Welcome to Geeklog, Anonymous Thursday, March 28 2024 @ 01:29 pm EDT

Geeklog Forums

Where is the best place to include javascript files


paslatek

Anonymous
I'm trying to use a javascript file for one of my blocks.
I don't know where to put the html statements for include this JS file.

- If I put in the "lib-custom" file, I'll get the "cannot modufy header" error.

- If I put in my theme template, this block will work only when using my theme.

any suggestion or idea please ?
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Script tags can be used anywhere in an HTML document, so unless it's something that you want to use multiple times but only load once, you could put it directly into your block.

Otherwise, use the function CUSTOM_templatesetvars in lib-custom.php to define your own header variable that contains your JavaScript code.

bye, Dirk
 Quote

paslatek

Anonymous
Thaks for your reply !

I've finally include my script in my block.

but at the start of my reflexion, I thought to include a script file with custom function for many of my blocks. So I search a "generic place" like a custom_functions.js to use.
If I understand what you said, I think that CUSTOM_templatesetvars will give me this ability ! Smile

Many thanks Dirk
 Quote

All times are EDT. The time is now 01:29 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content