We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26401
    • 247 Posts
    I just had this idea, but I’m not sure if it is possible to do.

    The idea is that I have a bunch of pages with static content, but would like a javascript and a css file to change. The js and css would be the resource (set through Internet Media Type).

    The css I can use to populate a random banner image, so because it is random I don’t need to worry about which page isactually being viewed. However, with the javascript I have a accordion menu in mind that I want to have open on the page that the js is loaded through.

    so if the resource R_1 loads R_js, I can have a snippet in there that will do something different than in R_2 is loading it.

    Is there anything inside modx that could tell me what page loaded this resource (or right before it) prefferably without without using any additional javascript, cookies or sessions?

      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: daspoda at Mar 29, 2010, 10:32 PM

      I just had this idea, but I’m not sure if it is possible to do.

      The idea is that I have a bunch of pages with static content, but would like a javascript and a css file to change. The js and css would be the resource (set through Internet Media Type).

      The css I can use to populate a random banner image, so because it is random I don’t need to worry about which page isactually being viewed. However, with the javascript I have a accordion menu in mind that I want to have open on the page that the js is loaded through.

      so if the resource R_1 loads R_js, I can have a snippet in there that will do something different than in R_2 is loading it.

      Is there anything inside modx that could tell me what page loaded this resource (or right before it) prefferably without without using any additional javascript, cookies or sessions?
      Not really other than making the links pass GET parameters to the Resources, and tbh, serving dynamic CSS and JS through MODx (or PHP in general for that matter) is going to significantly affect your site performance since those files will not be cacheable in the browsers like they normally would when served by the web server.
        • 26401
        • 247 Posts
        thanks for the input.

        serving dynamic CSS and JS through MODx (or PHP in general for that matter) is going to significantly affect your site

        I didn’t know this....