- Moderated by:
- Support Team
-
- rank:
-
Freshman
- registered:
- January 2008
- Status:
- offline
- last visit:
- 24.02.08
- Posts:
- 6
I have a module that has hardlinks to a javascript file that were pointing to the wrong place causing errors
(caught them thanks to firebug!)
I tried fixing the links by modifying the module's theme files to use the modulejavascript function i.e.as described here http://api.postnuke.…javascript.php.htmlCode
<!--[modulejavascript modname=foobar script=openwindow.js modonly=1 ]-->
but it isn't producing any script output. Am I missing something?
Is this the proper way to include scripts from within modules?
And where should the scripts be located? (I'm assuming the module's pnjavascript folder...)
Thanks!
-
- rank:
-
Helper
- registered:
- January 2003
- Status:
- online
- Posts:
- 216
Hi,
you might read the Ajax section in our wiki.
In general you need only one call which is the pnajaxheader.
Additional scripts can also be handled by the page vars.
--
-
Anonymous
- rank:
- 1
- registered:
- March 2002
- Status:
- offline
- last visit:
- 01.05.06
- Posts:
- 0
OK, read the Ajax part of the Wiki, it's not very clear how one should include javascript.
The module isn't using any Ajax, just some mouseover stuff.
The Wiki assumes the module has pnajax.php and other files present (it doesn't).
pnajaxheader seems to pull in other Ajax libraries (sriptaculous, etc.) which I don't need to do.
Is modulejavascript deprecated? Do I need to call something else before using it?
I can't figure out why the modulejavascript statement in my first post doesn't output
Code
that should read script type="text/javascript" src="modules/foobar/pnjavascript/openwindow.js" with brackets around it but the forums don't seem to be able to cope with two code listings in the same message.
Or should I just useCode
<!--[pnpageaddvar name="javascript" value="path/to/myscript.js"]-->
instead?
-
- rank:
-
Helper
- registered:
- August 2003
- Status:
- offline
- last visit:
- 22.11.08
- Posts:
- 465
Including a js in a module template would indeed be done with:
Code
<!--[pnpageaddvar name="javascript" value="modules/mything/pnjavascript/script.js"]-->
That will put the script tag with type="text/javascript" and src="modules/mything/pnjavascript/script.js" in the header of your page.
The link on Page variables from Guite describes it.
edited by: espaan, Feb 24, 2008 - 01:27 PM
--
http://www.erikspaan.nl
http://www.avwijchen.nl
Involved in: BlankTheme, StoriesExt, Menu templates, SmugView and zikula.nl -
- rank:
-
Freshman
- registered:
- January 2008
- Status:
- offline
- last visit:
- 24.02.08
- Posts:
- 6
Thanks, I also figured out in the meantime that
Code
<!--[modulejavascript modname='foobar' script='openwindow.js' modonly=1]-->
works.
Note the quotes around the modename and script parameters.
The documentation here and the documentation inside the function.modulejavascript.php file have it shown without the quotes (which doesn't work).
-
- rank:
-
Freshman
- registered:
- February 2008
- Status:
- offline
- last visit:
- 03.03.08
- Posts:
- 6
I am trying to get Mike's DHTML scroller to work and not having any luck. It sees the information and whatnot - but it don't scroll without throwing a hacking code in the pnWhichever module. -
- rank:
-
Helper
- registered:
- August 2003
- Status:
- offline
- last visit:
- 22.11.08
- Posts:
- 465
@TheAdmiral. It probably better if you openup your own topic on the subject.
Provide some more info: what do you want to scroll, demo link, what is pnWhichever actually. You have to be more specific. A link to Mikes DHTML scroller might be nice as well. People don't have to go look for themselves.
--
http://www.erikspaan.nl
http://www.avwijchen.nl
Involved in: BlankTheme, StoriesExt, Menu templates, SmugView and zikula.nl
