We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17851
    • 213 Posts
    I'm wanting to create a static resource of a PHP type so that I can reference it as a URL. I'm using it as the data source for an autocomplete text field. From what I've read this is possible, but I'm having issues.

    I've got a PHP content type setup and have tried several mime types (text/html, text/php, etc). How do I make this work?
      Mark Macatee
      President
      Power 10 Solutions
      http://www.power10solutions.com
      • 10487 MODX Staff
      • 1,535 Posts
      Create a snippet that handles the PHP processing and place that in your resource content. Make sure you call the snippet uncached as it sounds like your processing will rely on POST and/or GET parameters.

      You don't really need the PHP content type, you can keep it as HTML and just delegate all the PHP necessities to the snippet.
        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 17851
        • 213 Posts
        OK, that's what I'm already doing, but it looked like the static resource would let me do that as well.
          Mark Macatee
          President
          Power 10 Solutions
          http://www.power10solutions.com
          • 39194
          • 149 Posts
          No, static resource content is to be parsed by MODx. It can not be executed.
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Indeed. A static resource is only a resource whose content is stored in a file instead of the database; otherwise it is exactly like any other resource.
              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