PostNuke: A Flexible Open Source Content Management System
home | forum | international support | contact us

Support Forum

Start ::  PostNuke 0.7 Support ::  XTE Support ::  proper way to include javascript

Moderated by: Support Team

Bottom
proper way to include javascript

  • Link to this postingPosted: 23.02.2008, 12:22
    Profile
    NuclearFriendly
    rank:
    pnFreshman pnFreshman
    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.
    Code
    <!--[modulejavascript modname=foobar script=openwindow.js modonly=1 ]-->
    as described here http://api.post...ipt.php.html
    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!
  • Link to this postingPosted: 23.02.2008, 13:14
    Profile Homepage
    Guite
    rank:
    pnHelper pnHelper
    registered:
     January 2003
    Status:
    online
    Posts:
    140
    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.

    -----
  • Link to this postingPosted: 24.02.2008, 06:54
    Anonymous
    rank:
    1
    registered:
     March 2002
    Status:
    offline
    last visit:
    02.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 use
    Code
    <!--[pnpageaddvar name="javascript" value="path/to/myscript.js"]-->

    instead?
    icon_confused
  • Link to this postingPosted: 24.02.2008, 12:15
    Profile Homepage
    espaan
    rank:
    pnHelper pnHelper
    registered:
     August 2003
    Status:
    offline
    last visit:
    09.05.08
    Posts:
    237
    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
  • Link to this postingPosted: 24.02.2008, 15:08
    Profile
    NuclearFriendly
    rank:
    pnFreshman pnFreshman
    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).

    icon_rolleyes
  • Link to this postingPosted: 26.02.2008, 04:55
    Profile
    TheAdmiral
    rank:
    pnFreshman pnFreshman
    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.
  • Link to this postingPosted: 26.02.2008, 09:55
    Profile Homepage
    espaan
    rank:
    pnHelper pnHelper
    registered:
     August 2003
    Status:
    offline
    last visit:
    09.05.08
    Posts:
    237
    @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.

Start ::  PostNuke 0.7 Support ::  XTE Support ::  proper way to include javascript

Main Menu

Extensions Database

Documentation

Development

Login





 


 Log in Problems?
 New User? Sign Up!

Donate to PostNuke