Page 1 of 1

[Solved] add a javascript file to the admin section

Posted: Tue Feb 05, 2008 6:43 pm
by hostep
Hi there

I'm developing my own module, and it already goes very well.
But now i need some javascript on the admin side of the site.
And I can't find how to make a tag in the head of the admin pages without changing the theme.

Is this possible?
If yes, how?
If not, maybe there is another nice way to embed javascript on the admin side?


Thanks!

Re: add a javascript file to the admin section

Posted: Tue May 20, 2008 7:45 pm
by rayman22201
I also needed to add some javascript to an admin module and had the same trouble, and couldn't find an easy solution directly.

I ended up kind of cheating by embedding the script into an Iframe, passing any variables I needed from the module as GET variables in the SRC tag of the iframe... It is a really patchwork solution, but it worked in a hurry.
;D

Re: add a javascript file to the admin section

Posted: Tue May 20, 2008 10:55 pm
by hostep
Thanks for the reply, but in the mean while I already found the correct solution.

You just have to put the extra javascript tags in the GetHeaderHTML() function in the module.

That's much cleaner than your patchwork ;)

Re: [Solved] add a javascript file to the admin section

Posted: Tue May 20, 2008 11:08 pm
by calguy1000
I usually just embed the javascript into whichever templates I need, then there's no issue.

if I need the javascript in more than one template, I can use smarty's {include} tag.

Re: add a javascript file to the admin section

Posted: Thu May 22, 2008 6:10 am
by rayman22201
hostep wrote: Thanks for the reply, but in the mean while I already found the correct solution.

You just have to put the extra javascript tags in the GetHeaderHTML() function in the module.

That's much cleaner than your patchwork ;)
You know....I really need to read the api more closely....Then again I was in a really big hurry when I came up with the iframe solution, but either way, thanks, now I know how to do it the right way  ;D