We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27500
    • 14 Posts
    How can I call the MODx API from a standard HTML (non-MODx) page? Why would I want to do that? I have 1,000 picture pages from before I migrated to MODx. I’d like to update the navigation sections on their html template so at least the navbar automatically updates when I add new categories to MODx. Here’s an example I tried (that failed):

    <script language="php" src="/index.php?runSnippet=DropMenu&orderBy=menuindex,menutitle&startDoc=`0`&levelLimit=`1`" type="text/php"></script>

    A couple questions: Am I even pointing to the right .php file? Can I put an argument like "runSnippet=DropMenu" with args delimited by "&" and expect the result to be placed on the html page?
      • 22303 MODX Staff
      • 10,725 Posts
      You can’t, at least not in any way resembling what you have posted. You can use the MODxAPI add-on in the repository (and in the future you can use the MODx "API" directly, without the add-on) inside of external PHP files, but you cannot make calls to PHP using client-side script tags in HTML pages as you indicated; PHP is not a client-side scripting language. It’s interpreted by the server.
        • 26435
        • 1,193 Posts
        Did you take a look at the MODxAPI?
        It allows you to connect your external PHP pages to the MODx API.

        -sD-
        Dr. Scotty Delicious, Scientist.
          Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
          All of the above... in no specific order.


          I send pointless little messages
          • 27500
          • 14 Posts
          Thank you for the help; that’s what I needed to know. So, the modxapi.php is the file to point to but it will only work from a .php page and not a .html page.
            • 22303 MODX Staff
            • 10,725 Posts
            Quote from: skiphreak at Dec 11, 2006, 03:05 PM

            Thank you for the help; that’s what I needed to know. So, the modxapi.php is the file to point to but it will only work from a .php page and not a .html page.
            It will work from an html page, but only if you have your web server configured to parse PHP within pages having an .html extension.