We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11434
    • 3 Posts
    I’m just figuring out how the "Import HTML’ command
    in Modx works. It looks like Modx grabs the stuff between
    the <body></body> tags when it does an import.

    My question is what happens to any javascript functions
    that are defined between the <header></header> tags?
    What does Modx do with those and anything else between
    those tags?

    I can just hear someone advising me to put those javascript
    functions into a file.

    p.s. that’s a neat little trick that Modx does by adding "_base_href"
    to <img src= > tags, so that I only need to copy the image directories
    into the root of the document tree. It saves me from going around
    and changing the image path in every file.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Everything between other than the <body> content is expected to be in your template. You can make snippets or TVs for pages that need javascript code added and use the $modx->regClientScript and its sibling API functions to insert them as needed.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org